Hi,
I have a ITEMTemplate TextBox in a Gridview. I want to save values of Texboxes on button click. I am using following code ::
Source code:
cs file:
protected void Page_Load(object sender, EventArgs e)
{
GetDetails();
}
private void GetDetails()
{
da = new SqlDataAdapter("select column_name from testing.information_schema.columns where table_name = 'emp'", con);
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < GridView1.Rows.Count - 1; i++)
{
TextBox box1 = (TextBox)GridView1.Rows[i].Cells[0].FindControl("TextBox1");
string s = box1.Text;
}
}
But it is not working . I am getting s="" . please help me.
Thanks in advance.
Pankaj Singh
Loading
SenthilkumarPosted Apr 18, 2012, 10:22 PM
Please use this code to save the textbox value in the grid view.
But make sure the value is there in the textbox.
Hope this will help you.