.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

Base a dropdown on another dropdown in a gridview

Posted By:      Posted Date: October 17, 2010    Points: 0   Category :ASP.Net

I am not sure how to do this.  I know how to create a dropdown template on my gridview, but I would like to have the values based on another field in the row.  I have the dropdown associated with a datasource.  Can anyone give me an idea on how to do so?


View Complete Post

More Related Resource Links

Editable Gridview with Textbox, CheckBox, Radio Button and DropDown List

This is an example of an editable gridview containing different ASP.NET controls. When user wants to edit values in gridview, she/he can use these controls to edit existing values in Gridview Edit Mode.

Using the Code

Gridview with a dropdown list for editing


Hello. I am working through Scott Mitchell's ASP.Net in 24 hours book. I am finishing the photo album project.

I have a GridView that retrieves a list of uploaded photo rows for the logged-in user.
The GridView is for editing and deleting rows.

The photo Category field in the Gridview is a dropdown list. The text entry field was deleted after converting this field to a Template.

Like the uploaded photos, these Categories are user-specific. They are created in another web page.

Users also have the option to select "none" for the category when they upload an image.

For the GridView:  The Category ID field's ItemTemplate and EditItemTemplate both have a " - None - " choice added to them.

I am getting this error:

'pictureReadOnlyCategories' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value


Note: The ID for the ItemTemplate for that dropdown list is the ID listed above in the error: "pictureReadOnlyCategories".


Am I missing some step in this process of changing a GridViews text field to a dropdown that can be used for editing? I went through the book's instructions three times.

Here is my code for the dropdown list and a screenshot of the Design

binding datetimecontrol,dropdown,textbox inside gridview and update each gridviewrow

i have a web part with datetimecontrol(sharepoint) inside a  gridview. when the page loads this this gridview will be loaded with dtc control and the selecteddate would be one of the columns in the splist.also gridview contaisn dropdowns, textboxes, when an update button cliked inside grid, i need to save the info in the splist.  currently i am not getting the value  bound with dtc control. i am getting blank date inside dtc. though in the  rowdatabound event i amcapturing the values due to some reason i am not able to view the value in the DTCcontrol. can anybody give me help me how to achieve this? any  help links/ sample code.. appreciate the help                         

dropdown tht inserts data vis procedure if the gridview doeant have value for the dropdown selection

i have a dropdown with month names if the user has data for the month tht is selected then gridview displays the rows with day nos as per the month but if the gridview has no data for the same the dropdown or gridview via some event should call a insert procedure to insert data into the table for tht month with daynos ad rebind the gridview witht the rows just created Can anyone help very urgent  Michelle

Gridview Editing with dropdown lists inside

  Hi, Any good  Example for Editable Grid with dropdownlist inside ? Getting some problem in updating the data   Thanks 

Dropdown select message in item template gridview dropdwon list ???

Hi ....I have used gridview item template , which has two dropdown list .The first dropdown list is binded from database to the dropdown list I have using the below code , to show the select message in dropdown list before selecting any item from dropdown list.In first row its show me --Select-- message and my vaues.. if i select some value form dropdownlist and click add new button it will create a new row dynamic then in previous row again it come back --Select-- message... on going to second row....I need to remain first row user selected value on going to next row.The New row will show --select-- message..Please go to my code and let me know what to do<asp:DropDownList id="DropDonList2" tabIndex=11 runat="server"          OnSelectedIndexChanged="DropDonList2_SelectedIndexChanged" AutoPostBack="True"          DataTextField="SizeRange" DataValueField="SizeRange"          OnDataBound="DropDonList2_DataBound" __designer:wfdid="w10"          AppendDataBoundItems="True">  <asp:ListItem Value="-1">Select</asp:ListItem> </asp:DropDownList><asp:DropDownList id="DropDonList2" tabIndex=11 runat="server" 

change index of dropdown in gridview


 i have got grid view with 4 coloums which contains 2 dropdown list. n i have 2 drop down list out side the gridview .

i want to change the index of the 1st coloum  dropdown list inside the gridview when changing the drop down list  index outside using javascript

similarly the when the 2nd dropdown list(out side ) index change the 2nd coloumn dropdown list in gridview should change..

 In short the outside placed dropdown list should act as master dropdown list.

GridView Edit DropDown


I have a gridview that has an edit button.  I want to have dropdownlists in the edit template, which I have.  I cannot get the dropdowns into the update sql.  Is that done with code behind or is there another way to do it? 

<asp:GridView ID="GridView4" runat="server" AllowSorting="True" 
            AutoGenerateColumns="False" CellPadding="9" DataSourceID="SqlDataSource4" 
            ForeColor="#333333" GridLines="Vertical" DataKeyNames="idx" Font-Size="Small" 
            Width="746px" Font-Bold="False" Font-Underline="True" CssClass="style4">
            <RowStyle BackColor="#E3EAEB" Font-Bold="false" Font-Underline="false" />
                <asp:CommandField ShowEditButton="True" />
                <asp:BoundField DataField="idx" HeaderText="idx" InsertVisible="False" 
                    ReadOnly="True" SortExpression="idx" />
                <asp:BoundField DataField="problem" HeaderText="problem" 
                    SortExpression="problem" />
                <asp:TemplateField He

How to bind two different list to dropdown base on radiobutton selection

  I have radio button and dropdown column types in sharepoint list, and apart from this i have two list. I want to bind the data to data from the two list base on the selection of radio button. If i select 'Yes' i want to bind from the one of two list, and when i select i want to bind it to another list. Is it possible in sharepoint ?. If yes can you help me out in this

Using asp:dropdown lists to filter Gridview.


I'm trying to create a page with multiple fields to be used as parameters for filtering a GridView.  I'm using a combination of two asp:dropdown lists and two check boxes.   When I select a value in one ddl, I want to clear the value in the other ddl.  I was trying to use the event "onTextChanged" but that doesn't seem to fire off on the client side and I cannot seem to find any event for an asp:ddl or asp:checkbox or asp:radio button that fires off on the client side. 

Are there events, like onClientClick for asp:button, that fire on the client side for these controls when a selected value is changed or when the user clicks on them?

or do I need to use html controls instead?

Thanks for your help.

Dropdown in gridview


hi everybody,

can someone help me out please.

i have a dropdown where we can select set of employees,based on the selection i want another dropdown within the grid to be populated with all the projects associated with him

thank you

Dropdown List in Gridview - While saving the record in gridview the droppdown selected index are cha



I am developing page for maintaing employee record using Visual Studio 2008, MS SQL server 2005.

I am able to fetch and display all the employee information in gridview, the gridview have the dropdown list to display the employee type [ Part Time, Full Time, Permanent , Contract ], in the item template i am having dropdown list. IN the dropdown list i am displaying this.

But While saving the record in gridview the droppdown selected index are changed to 0 of other dropdown list.

the user may be change the dropdown value from permanent to contract, or so. but while click on the save button in gridview, all the previous selection are gone, and always showing the first record of dropdown list. I know this is happening because we are doing dropdown list bind on onRowDataBound.

But i want to retain all the user selection in gridview, please help me how to do this.

thanks in advance.

on dropdown selection label display respected value inside gridview



Here i am using dropdown that will retrive from database when i will select an item from dropdownlist then item rate display on the selection of dropdown item name.

how will do this???


If Dropdown list value is available in the binded gridview in any row , then i need to show a messag


Hi ...
If Dropdown list value is available in the binded gridview in any row , then i need to show a message ALREADY EXIST !
I have a gridview which has 3 columns and binded from database on pageload.
In the same page i have 3 dropdown list which is also binded from database.

Set a data source for DropDown List inside GridView


How do i set a data source of  a drop down list which is inside a grid view, snap shot of asp code given below , the Asp file name is DataEntry.aspx and there is method in the DataEntry.aspx.cs called DTB.BindData("Department"). i want to set the datasource to point to this method


<asp:GridView ID="GridViewEmply"  DataKeyNames="EmployeeID" runat="server"
 AutoGenerateEditButton="True" ShowFooter="True"
OnRowEditing =  "GridViewEmply_RowEdit" OnRowCancelingEdit = "GridViewEmply_RowCancelingEdit"
OnRowUpdating = "GridViewEmply_RowUpdating"  OnRowCommand = "GridViewEmply_RowCommand"
AllowSorting="True" AutoGenerateColumns="False" AllowPaging="True"  Visible="false">
<asp:TemplateField HeaderText="DepartmentName">
<asp:Label ID="LabelEmplyDeptName" Text='<%# Eval("DepartmentName") %>' runat="server"></asp:Label>
<asp:DropDownList ID="ddlDept" runat="server" >

Dropdown, checkbox and textbox controls in asp.net editable Gridview.

In this article, I will explain how to use dropdown, checkbox and textbox controls in gridview while insert and edit records.

Dropdown list in ASP.NET - How to get value selected

am sure this must be very simple, but unforunately I can't figure it out.
I have the following code which populates the dropdown lists from the database. This works fine. Now, when the user selects a particular employee name from the list, I want to get the Employee Id of the selected employee. i.e. I need to get the "Eid" value. I can do this if the EId is loaded in the dropdown list, but in this case only the employee name is displayed. Please let me know howI can get the Eid value even though it is not loaded in the dropdown list.
I would really appreciate your help
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