Click here to Skip to main content
16,023,001 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have two dropdown inside the gridview
Like DDL1 and DDL2
On the change event of DDL1 second dropdown DDL2 is binding.
But my problem is when Ist time page is loading my both dropdowns are not populating value which are coming from database.
SEcond Dropdown DDL2 i can understand it would not bound but Ist Dropdown DDL1 should display value from database .
How should i do it?

Thanks
Posted
Comments
Sandeep Mewara 10-May-12 9:07am    
It would be difficult for anyone to tell what could be going wrong without seeing your code related to it.
Herman<T>.Instance 11-May-12 7:08am    
bind it in the onrowdatabound event of the gridview

1 solution

XML
try this ,first take a template field then add item template,then inside edit template put the dropdown as follow...

<asp:templatefield headertext="Status" sortexpression="with_status" xmlns:asp="#unknown">

<asp:label id="Label1" runat="server" text="<%# Bind("with_status") %>">



<asp:dropdownlist id="DropDownList1" runat="server">
<asp:listitem value="0">-Select-
<asp:listitem value="1">pending
<asp:listitem value="2">completed






aspx.cs

on rowupdating put the following code

DropDownList ddl2 = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("DropDownList1");
if (ddl2.SelectedValue.ToString() != "0")
{
SqlDataSource1.UpdateParameters["with_status"].DefaultValue = ddl2.SelectedItem.ToString();

}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900