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
What is difference between an Structure and Class?
How do I know if executenonquery is successful c#?
What is dataset c#?
Is c# and c same?
What are the advantages of generics in c#?
Describe two uses of the “using” statement during the operation of c#?
What does typeof return c#?
What is lambda expression in c#?
Why dictionary is used in c#?
Can a class be protected in c#?
What is session c#?
What is an array class?
code for arranging given number in possible permutation ways ex:123,321,312,132,231,213.
What are the 2 broad classifications of data types available in c#?
Are cao stateful in nature?