![](/img/trans.png)
[英]GridView within an UpdatePanel - Get Updated Textbox values on button click
[英]How to get values of textbox and dropdownlist controls in a gridview on a button click event?
在頁面加載上,將有一個帶有默認行的gridview ....在底部有一個帶有+號的按鈕...在該按鈕上單擊我想在網格中創建一個新行..在此之前,我需要確保所有字段都有值。但是我得到的是空值。
我的代碼是:
TextBox name_value = ((TextBox)Gridview1.Rows[0].FindControl("TextBox1"));
TextBox age_value = ((TextBox)Gridview1.Rows[0].FindControl("TextBox2"));
DropDownList sex_value = ((DropDownList)Gridview1.Rows[0].FindControl("DropDownList1"));
DropDownList berth_value = ((DropDownList)Gridview1.Rows[0].FindControl("DropDownList2"));
任何幫助將不勝感激。
請將此代碼寫在代碼Gridview1.EditIndex-1
末尾,不確定EditIndex或Edititemindex,請嘗試使用它可能會對您有所幫助。
嘗試使用條件
if(name_value.Text!="" && age_value.Text && sex_value.Text && berth_value.Text)
{
//action
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.