.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

filtering a dropdown on a DD insert page

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :ASP.Net

is there any way of filtering the rows that are show in a dropdown box that is auto-generated from a foreign key relationship a DD insert page. bascially i want to show a subset of the records from the lookup table along the lines of "WHERE UserSelectable = 1"

any help grateful;ly appreciated

View Complete Post

More Related Resource Links

How to refresh page and dropdown after insert record from popup page


I have a page that is opened in a popup window from the main page. Once i click insert it pops up a message that says you have successfully added blah blah. Then once you click ok it closes the popup page and goes back to the main page. I want to be able to refresh the main page back to how it was when you first land on the page. Here is the code for my insert button:


 <asp:button id="insertButton" 
                    style="background-image:url('Images/Button.gif'); text-align:center;background-color:Transparent; cursor:hand; background-repeat:no-repeat; background-position:left; padding-left:15px; font-family: 'Arial Unicode MS'; font-size: small; font-weight: bold;" 
                    Runat="server" Height="25px" BorderStyle=None ForeColor=White    Text="Insert" 
                    Width="99px" CssClass="style13" CommandName="Insert" OnClientClick="javascript: alert('You have successfully added a New Donor!!');window.open('','_self','');window.close();" />


Detecting Edit or Insert Page


I am coding a .cs file that handles the metadata for a particular table. I am putting a custom validation that allows me to update or insert only if the PubMedID is not already in the database. This would be easy except that the PMID should also be allowed to be null as some of the references in the database were not from PubMed. So i perform a query on the database to see if there is already an identical PMID in the database. This works great when using Insert. However, when using Edit, it does not. The PMID is already in the database because the one currently being edited has the same PMID!!! So I know exactly how to change my query etc. However, I do not know how to tell from inside this Edit/Insert agnostic page, which one it is being called from. Thanks for your help! 

Retain DropDown,TextBox's previously selected values after redirected from another page.


 Hi People, How are you all doing?

I have 2 pages one is SearchPage & It has DropDowns, textboxes to specify the search criteria. From the search result the user is redirected to another page when he clicks the hyperlink in the search result  where he fills in the information and again redirected to SearchPage. Now the SearchPage is posted back with no state i just want to retain the search criteria and display when user comes back. Please give me some suggestion how to get this done. I've used ViewState to save the values and check them in Page_Load but they are null.   



 Update: I've come up with this code. But the problem is The values are being retained but the Button_Click event is not being handled properly. When i Check the code even after this "DropDownList1.SelectedValue = Session["Name"].ToString();" DownList1.SelectedValue is EMPTY"" samw with DropDownList2 . please Suggest something


    protected void Page_Load(object sender, EventArgs e)
        if (IsControlsEmpty())
            if (SessionExist())
                DropDownList1.SelectedValue = Session["Name"].ToString()

Insert a "Select User" row in Linq for a dropdown list

I'm new to Linq. I have searched and searched the web for a soluion, and can't find anything. I have a Linq query and I want to insert a row ("Select User") to the top before I pass it to the drop down list. I've been trying to use the Union but to now avail (it keeps telling me that my object doesn't support the Union method). My code, prior to attempting to inser a row, is very simple.public SelectList DropDown_Users()        {            var context = new VivarianDataContext();            var query = from t in context.AspnetUsers                        select new { t.UserId, t.LastName };            list = new SelectList(query.AsEnumerable(), "UserId", "LastName");            return list;        }Now I try to insert a row and I found this on the internet and it seems to say that his solution will work. But it is filled with syntax errors. http://magicode.wordpress.com/2009/08/20/inserting-an-item-in-iqueryable-object-using-union-met

Need help when selecting an item from one dropdown list it populates the 2nd dropdown on aspx page

Does anyone know how to do this so when I select something the 1st dropdown and the 2nd one becomes visible and populates list from a Select statement. I really need help on how to do in an aspx and not on the code behind page.

Filtering web parts without reloading the whole page

I don't know if this is possible or not, but I am going to ask anyway. I have several performancepoint reports on one page, all connected to different filters. I was wondering if there is a way to make only the report you are changing the filter on reload.  For example, I have a census of people that uses a time intelligence filter to show different periods of time.  If someone selected, "Last Six Months," on the filter, I would like just that census report to reload, as opposed to the whole page, which has to reload about 5 other reports. Is there a way to do this?

how to insert data into database from content page?


Please help me to insert data to database from a content page of a master page. My code is working fine when i use my code without master page but with content page of master page i dnt knw what goes wrong. Help me on this please.

thank you

I have my insert logic in my class, how do i output the return value on my page to use with another


I have the following portion in my class, i need to get the value of the inserted record so i can use in another insert that im doing with a loop, so i need to add another variable to my

"public void insertServ( string EmLogin, string EmPass, int Emnum )"  the procedure is already returning the value i need, just need to get it back on the page so i can use it with my next insert.



                cmd.Parameters.Add("@EmLogin", System.Data.SqlDbType.VarChar).Value = EmLogin;
                cmd.Parameters.Add("@EmPass", System.Data.SqlDbType.VarChar).Value = EmPass;
                cmd.Parameters.Add("@EmNum", System.Data.SqlDbType.Int).Value = EmNum;

                cmd.Parameters["id"].Direction = ParameterDirection.ReturnValue;

            catch (System.Data.SqlClient.SqlException ex)
                string msg = "Server Email Insert Error:";
                msg += ex.Message;
                throw new Exception(msg);


Correct Way to Insert Data from Text Boxes on ASPX page into SQL Database Using VB


Please help me, I have been trying this for a week now and this is how far I have gotten.


I am new to this, and I am using MS Visual Web Developer Express.


OK - This is what I have come up with, but when I run it I get the following error  (I decided to just try to use a simplified table just to get an understanding of the basic concepts):



Partial Class label_form
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' Declaring variables
        Dim username, labelname, ownersname, address1, address2, city, state, zipcode, country, contactnumber, emailaddress, data_source, con, sql_insert

        ' Check if Necessary Text Is Missing ( will do this once I can get it to work with no empty text boxes)

        ' Get Values from TextBoxes
        username = txtUserName.Text
        labelname = txtLabelName.Text
        ownersname = txtOwnersName

Form View: Filtering Drop down on insert using objectdatasource



I have a grid view which display different phone types with insert,edit and delete options.

During insert in the modal formview I have dropdown for different phone types which is bound to an
object datasource. The object datasource displays all the available phone types including the ones
displayed in the gridview

How do I display only the values that is not in the gridview. I tried setting the object datasource to a different one
and it does not work ( in Item created event). It display no values in the dropdown when I know there is more than 1 availble.

How do I change the object datasource during insert or how do I filter the values in the dropdown.




protected void FormViewOnlinePhone_ItemCreated(object sender, EventArgs e)
         FormView fvPhone = (FormView)FindControl("FormViewOnlinePhone");

         DropDownList dropdownUsage = (DropDownList)fvPhone.FindControl("DropDownListPhoneType");
         DataSet dsType = new DataSet();
         if (FormViewOnlinePhone.CurrentMode == FormViewMode.Insert)
            dsType = psClass.GetInsertPhoneTypes(application_id);
              dropdownUsage.DataSource = dsType.Tables["usage"];

using ForeignKey.ascx in the Insert page instead of ForeignKey_Edit.ascx



in my insert page the dropdown list is too long. it is slowing down my insert page.

I want to use the Hyperlink instead of the dropdown  in my insert page (exactly same like what i have in my edit page).

my insert page will have always foreign key Initialized values .

insert or update I will not allow my user to edit his foreign key (i am fine with that )


Persisting DropDown List attributes accross page Postbacks


Can anyone advice how can DropDownList attributes be persisted accross page Postbacks?


DropdownList1.AutoPostBack = True

On Postback the attribute is no longer available (ie. attributes.count=0).
I tried persisting using the code below, but was unsuccessful:

Before PostBack: ViewState.Add("DDL","DropdownList1")
On PostBack: DropdownList1 = ViewState("DDL")

This generated the error: DropDownlist is not marked as serializable.

I than tried:

Before PostBack: Session.Add("DDL","DropdownList1")
On PostBack: DropdownList1 = Session("DDL")

This did not err but attributes were still not available.

Ideas Anyone?








Insert page with master/detail


I have a case where I want to insert personal data and on the same page to be able to insert contact information, meaning entering more than one contact like e-mail,phone no ect. and contact data are saved to another table(it's like saving order info and order details at the same time)

is there a way to build this kind of page using dynamic data.

any link to an example would be very helpful


Dropdown list value to insert into database


I have a dripdownlist

<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="NameSource"
           DataTextField="Choice" DataValueField="Appliers" AutoPostBack="True">

I want to insert into database with the following code. I want the  Appliers instead of Choice to be inserted. Now this code insert the Choice field only. How should I modify this code ? Thanks

e.Command.Parameters("Name").Value = DropDownList1.SelectedValue

I tried SelectedItem it becomes error too... help...

how to call dropdown SelectedIndexChanged event in page load event in c#


Hi everyone,

in my web form i have a department dropdown box, in its selectedIndexChanged event i have to fill the equipment dropdown box and in equiment dropdown selectedIndexChanged i have to fill out the other textboxs.

the depratment dropdown box get its value from sqldatasource.

 <asp:DropDownList ID="dp_deptname" runat="server" DataSourceID="SqlDataSource1" DataTe

Filtering Page contents by User's City

I have set a profile column for WorkCity and would like to display news and weather specific to that user's home location no matter where he or she logs in.  I am doing this in SharePoint 2010 Standard and do not have Profile synchronization set up.  Is there any way to do this?

How to assign a initial default value on INSERT PAGE


Hi, I'm learning Dynamic Data right now, and I'm stuck with this problem.

I have 2 tables in a database; Doctors and Specialties. I'm using ASP.NET Dynamic Data Website to handle these data.

For Doctor table, I don't have Identity property on doctor_ID column. So when I want to insert a new doctor, I want my INSERT PAGE automatically generate a new ID by checking the last ID and then being increased by one. I know how to get this.

But, my question is, how to assign this new doctor ID value to the appropriate field on Doctor Insert Page only when I open it to add new doctor?

It won't be applied on Specialties Insert Page. Thanks.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend