Reputation: 1216
I have a GridView
with some ItemTemplate
and I need to work with the SelectedIndexChanged
event... I manually wrote the codes but it's not working... Check it out:
HTML
code:
<asp:TemplateField HeaderText="PROJETO" HeaderStyle-Width="90px" ItemStyle-HorizontalAlign="Center" ItemStyle-Font-Size="12px">
<ItemTemplate>
<asp:DropDownList ID="Drop_Projetos" Width="115px" runat="server" OnSelectedIndexChanged="Drop_Projetos_SelectedIndexChanged" EnableViewState="false"
AutoPostBack="true"></asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
And here's my codebehind
, where I've put a breakpoint
but it isn't even fired...
protected void Drop_Projetos_SelectedIndexChanged(object sender, EventArgs e)
{
//SomeCode
}
Upvotes: 0
Views: 2188
Reputation: 17614
Missing autopostback in the drop down list AutoPostBack="true"
<asp:DropDownList ID="Drop_Projetos" Width="115px" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="Drop_Projetos_SelectedIndexChanged" EnableViewState="false">
</asp:DropDownList>
Here is a similar question which may help you
How can I add cascading drop downs inside of a gridview for edits?
Implementing cascading DropDownList binding in a templated control
Upvotes: 1
Reputation: 50728
You have to add to the DropDownList:
AutoPostBack="true"
Then it will post back to the server.
Upvotes: 1