Click here to Skip to main content
15,897,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I keep a DDL 'AmtddL' inside a template field of GV3. I want to select a value from this DDL and I use event handler 'OnSelectedIndexChanged' with this DDL. I already have this event handler with GV3. I get the error: 'No overload for 'ddlselectedindexchanged' matches delegate System.EventHandler'. I submit the codes.


C#
protected void ddlselectedindexchanged(object sender,GridViewRowEventArgs e)  //district ddl
   {
       var ddlsample = (DropDownList)e.Row.FindControl("AmtddL");

       if (ddlsample.SelectedIndex == 0)
       {

       }
       else
       {


XML
<asp:GridView ID="GridView3" runat="server" HorizontalAlign="Center"  AutoGenerateColumns="False"   OnRowDataBound="gvUserInfo_RowDataBound"
         style="border-color: #808000; top: 480px; left: 77px; position: absolute; height: 84px; font-size:small;
         width: 1100px" PageSize="5" AllowPaging="true"
         onselectedindexchanged="GridView3_SelectedIndexChanged">
         <Columns >
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkSelect5" runat="server"   />
</ItemTemplate>
</asp:TemplateField>
</Columns>

            <RowStyle HorizontalAlign="Center" />
            <Columns>


 <asp:TemplateField HeaderText="AmtddL">
<ItemTemplate>
<asp:DropDownList ID="AmtddL" runat="server" Width="84px" OnSelectedIndexChanged="ddlselectedindexchanged"/>
</ItemTemplate>
</asp:TemplateField>
Posted
Updated 22-May-18 17:18pm

Use EventArgs instead of GridViewRowEventArgs.
C#
protected void ddlselectedindexchanged(object sender, EventArgs e)
{
    //do something...
}

Also set AutoPostBack="True" for DropDownList.

Refer- Gridview DropDownList Selected Index Changed Event & Get GridView Row Index[^]
 
Share this answer
 
v2
Comments
S.Rajendran from Coimbatore 14-Dec-13 10:18am    
I did as said by you. I get the error like: Error 111 'System.EventArgs' does not contain a definition for 'Row' and no extension method 'Row' accepting a first argument of type 'System.EventArgs' could be found (are you missing a using directive or an assembly reference?)
That is because you are using e.Row, which is not contained in EventArgs. You should get the DropDownList as below as suggested in the link.

DropDownList ddlsample = (DropDownList)sender;
S.Rajendran from Coimbatore 14-Dec-13 10:32am    
Well. It works. Thanks.
Most welcome. :)
this question is something i am having issue with. i don't see any resolution? anybody have any ideas?
 
Share this answer
 
Comments
Richard Deeming 23-May-18 13:52pm    
If you want to ask a question, then ASK A QUESTION[^].

DO NOT post your question as a "solution" to someone else's question.

This question already has a resolution, which was posted and accepted 4½ years ago.

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