2012-04-05 47 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)

相關問題