我在GridView中有下拉列表(实际上有一堆),但我只关心其中一个。我需要捕获用户进行新选择以查看是否要将项添加到下拉列表中。这是我的代码..
这永远不会被称为:
protected void DebtorDropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = GridView1.Rows[GridView1.EditIndex];
DropDownList list = (DropDownList)row.FindControl("DebtorDropDownList");
string temp = list.SelectedValue;
}
这是ASP代码:
<ItemTemplate>
<asp:DropDownList ID="DebtorDropDownList" AppendDataBoundItems="true" runat="server"
DataSourceID="SqlDataSource4" DataTextField="FirstName" DataValueField="contactkey"
SelectedIndexChanged="DebtorDropDownList_SelectedIndexChanged" AutoPostBack="True" >
<asp:ListItem Selected="True">Select</asp:ListItem>
<asp:ListItem >Add New Contact</asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource4" runat="server"
ConnectionString="<%$ ConnectionStrings:AuditDevConnectionString2 %>"
SelectCommand="sp_fc_vm_getSpokeTo" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" DefaultValue="0" Name="DebtorKey"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</ItemTemplate>
我错过了什么?我还使用正确的代码来找到正确的控件吗?
答案 0 :(得分:0)
我发现了我的问题。如果仔细查看我的ASP,你会发现“SelectedIndexChanged”事件缺失“on”