dropdownlist の indexchange イベントで hiddenfield に値を代入しようとしています! 実際の問題は、レコードを更新しようとしているときに、その非表示フィールドの値が見つからないことです! 親切に解決策を教えてください。または別のオプションを提案してください。ありがとう !
私のグリッドビューは
<asp:TemplateField HeaderText="LocCode" SortExpression="LocCode">
<EditItemTemplate>
<ajax:UpdatePanel ID="upEditsLocation" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="ddlLocation" runat="server"
DataSourceID="sdsLocation"
OnDataBound="ddlLocation_DataBound"
DataValueField="LocCode" AppendDataBoundItems="false"
DataTextField="LocCode"
AutoPostBack="true"
onselectedindexchanged="ddlLocation_SelectedIndexChanged">
</asp:DropDownList>
<asp:SqlDataSource ID="sdsLocation" runat="server" ConnectionString="<%$ ConnectionStrings:ccConnString %>"
ProviderName="<%$ ConnectionStrings:CCConnString.ProviderName %>" SelectCommand="Select LocCode from Location">
</asp:SqlDataSource>
</ContentTemplate>
</ajax:UpdatePanel>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblLocation" runat="server" Text='<%# Bind("LocCode") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
私のindexchangeイベントは
protected void ddlLocation_SelectedIndexChanged(object sender, EventArgs e)
{
hdloc.Value = ddlLocation.SelectedItem.Text;
}
そして私の隠しフィールドは
<asp:HiddenField ID="hdloc" runat="server" />