On the page load there will be gridview with a default row....there is a button with a + sign at the bottom...on the button click i want to create a new rows in the grid..before that i need to make sure that all fields have values.But I am getting null values..
My code is:
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"));
Any help will be appreciated.
请将此代码写在代码Gridview1.EditIndex-1
末尾,不确定EditIndex或Edititemindex,请尝试使用它可能会对您有所帮助。
Try using a condition
if(name_value.Text!="" && age_value.Text && sex_value.Text && berth_value.Text)
{
//action
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.