【发布时间】:2012-04-05 12:54:15
【问题描述】:
我们正在将 ASP.NET 用于我们的一个项目。然而,当我们试图读取我们在链接点击的回调函数中使用的 DropDownList 的 SelectedItem 或 SelectedValue 属性时,我们没有得到正确的 SelectedItem。
<FooterTemplate>
<asp:DropDownList ID="cmbTesters" ClientIDMode="Static" runat="server" Width="300px" DataSource='<%# PopulateTesterNames() %>' DataTextField="FullName" DataValueField = "PK_ID"></asp:DropDownList>
</FooterTemplate>
这是 aspx 文件中的 DropDownList。下拉菜单出现在 GridView 的页脚行中。我们在单击链接时调用以下代码集。
if (int.TryParse(((DropDownList)dgCreateCPRVerificationResponse.FooterRow.FindControl("cmbTesters")).SelectedValue, out TesterID))
{
TesterID = int.Parse(((DropDownList)dgCreateCPRVerificationResponse.FooterRow.FindControl("cmbTesters")).SelectedValue);
}
我们面临的问题是,无论我们选择什么值,SelectedValue 始终是列表中的第一项。我们正在使用 global.asax 文件中定义的基于 REST 的 URL。另请注意,这不是基于任何框架构建的。
请尽快帮忙
【问题讨论】:
-
你检查过回发吗?
标签: asp.net rest gridview drop-down-menu