我有GridView
一些ItemTemplate
,我需要处理SelectedIndexChanged
事件...我手动编写了代码,但它无法正常工作......请查看:
HTML
代码:
<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>
这是我的codebehind
,我放了一个breakpoint
,但它甚至没有被解雇......
protected void Drop_Projetos_SelectedIndexChanged(object sender, EventArgs e)
{
//SomeCode
}
答案 0 :(得分:1)
在下拉列表AutoPostBack="true"
<asp:DropDownList ID="Drop_Projetos" Width="115px" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="Drop_Projetos_SelectedIndexChanged" EnableViewState="false">
</asp:DropDownList>
这是一个可能对您有帮助的类似问题
How can I add cascading drop downs inside of a gridview for edits?
Implementing cascading DropDownList binding in a templated control
答案 1 :(得分:1)
您必须添加到DropDownList:
AutoPostBack="true"
然后它将回发到服务器。