0
我正在通过选择下拉项目添加新记录时遇到问题。基本上这是一个gridview,我选择AddressType,国家然后城市CityArea等使用下拉菜单。在第一次尝试中它工作正常,但在第二次尝试时,我选择国家它重置选定的项目。DropDownList刷新第二次尝试在GridView asp.net c#
http://i.stack.imgur.com/GoTtU.jpg
,你可以在上面的图片中看到,在第二次尝试,我要选择国家。只要我选择国家它刷新。看看在下面的图片:
http://i.stack.imgur.com/ObeT5.jpg
请帮我找到解决方案。 谢谢。
这里是我的代码:
<asp:TemplateField HeaderText="Country" HeaderStyle-Width="14%">
<ItemTemplate>
<asp:Label ID="lblCountry" Text='<%# DataBinder.Eval(Container, "DataItem.Country.Description") %>'
runat="server"> </asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:UpdatePanel runat="server" ID="UPCountry">
<ContentTemplate>
<asp:DropDownList ID="ddlCountryNew" DataSourceID="odsCountry" runat="server" OnSelectedIndexChanged="ddlCountryNew_SelectedIndexChanged"
AutoPostBack="true" DataTextField="Description" DataValueField="Id" CssClass="myWidth-7" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlCountryNew" />
</Triggers>
</asp:UpdatePanel>
</FooterTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlCountry" DataSourceID="odsCountry" runat="server" SelectedValue='<%# DataBinder.Eval(Container, "DataItem.CountryId") %>'
DataTextField="Description" DataValueField="Id" CssClass="myWidth-6" ValidationGroup="EditAddressGroup" />
</EditItemTemplate>
</asp:TemplateField>
C#:
protected void ddlCountryNew_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddlCountryNew = (DropDownList)sender;
hdnCountryId.Value = ddlCountryNew.SelectedItem.Value;
}
没有..仍然有问题。 –
你可以把你的整个代码显示到http://jsfiddle.net/并给 – BNN