Answer Posted / sudheer
parent control raised the child control events.ex:In the
grid view we are placing the one dropdown.But dropdown can't
raised the onselectedIndexchanged event.Just follow the
below code
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False"
onrowcommand="GridView1_RowCommand"
onrowdatabound="GridView1_RowDataBound">
<asp:TemplateField>
<ItemTemplate>
<asp:DropDownList ID="ddlItems" runat="server"
DataSource='<% #BindCombo() %>' DataValueField="AuthorID"
DataTextField="author"
OnSelectedIndexChanged="ddlItems_SelectedIndexChanged"
AutoPostBack="true">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
protected System.Data.DataSet BindCombo()
{
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXml(Server.MapPath("./XmlFiles/DBFile.xml"));
return ds;
}
protected void ddlItems_SelectedIndexChanged(object sender,
EventArgs e)
{
foreach(GridViewRow row in GridView1.Rows)
{
DropDownList ddlList =
(DropDownList)row.FindControl("ddlItems");
string items = ddlList.SelectedItem.Text.ToString();
}
}
Is This Answer Correct ? | 8 Yes | 0 No |
Post New Answer View All Answers
Can you create an instance of a static class?
What is c# windows form application?
Why do we use interface in c#?
If the interface in c# only contains the declaration of the methods and we need to define those methods in the class, then why we use the interface?
Differentiate between method overriding from method overloading with its functionality?
Why we use delegates in c#?
How to do and Apply Themes to Datagrid,Lable,Textbox,etc., in C#.NET 2005 Windows Application? (like who we will do themes in ASP.NET using .CSS and .SKIN files). Urgent!!
What is a dbml?
My switch statement works differently! Why?
Explain code compilation in c#.
How does yield return work c#?
What is an assembly in dotnet?
What is meaning of type safety in c#?
What is dll in vb.net?
What are scriptable objects?