2012-04-05 74 views
1

我们对我们的项目之一使用ASP.NET。但是,当我们试图读取我们在链接单击的回调函数中使用的DropDownList的SelectedItem或SelectedValue属性时,我们没有得到正确的SelectedItem。ASP.NET DropDownList不正确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。还要注意,这不是建立在任何框架上的。

请尽快

+0

在GridView你检查** **回传? – 2012-04-05 13:00:32

回答

0

帮助确保把下拉列表的结合方法和内部if (!IsPostBack)