binding the data to the grid
-
hi all iam having a grid in my application which has 4 columns of which 1 column i set visible=false.i want to bind the value of that column to the textbox.since the bound column is not visible the data is not coming in the textbox.can anyone tell me how to bind the data.
pintoo
-
hi all iam having a grid in my application which has 4 columns of which 1 column i set visible=false.i want to bind the value of that column to the textbox.since the bound column is not visible the data is not coming in the textbox.can anyone tell me how to bind the data.
pintoo
Hi Chithra! You must have some DataSource to bind a Grid. So directly set that column value to the TextBox. Suppose you have DataTable as DataSource then try this. DataTable dt = new DataTable(); if(dt!=null) { if(dt.Rows.Count>0) { TextBox1.Text = dt.Rows[0][4].ToString(); YourGrid.DataSource = dt; YourGrid.DataBind(); } } I hope this will help you. :) Regards..
"Save water,It's precious" :)
-
Hi Chithra! You must have some DataSource to bind a Grid. So directly set that column value to the TextBox. Suppose you have DataTable as DataSource then try this. DataTable dt = new DataTable(); if(dt!=null) { if(dt.Rows.Count>0) { TextBox1.Text = dt.Rows[0][4].ToString(); YourGrid.DataSource = dt; YourGrid.DataBind(); } } I hope this will help you. :) Regards..
"Save water,It's precious" :)
hi thanx for the reply.but i have binded the data already.i want to retrieve the data from the gridview but not from the data table directly(data is present in the grid but the visible property is set to false.)i want to retrieve the data from the grid.
pintoo
-
hi thanx for the reply.but i have binded the data already.i want to retrieve the data from the gridview but not from the data table directly(data is present in the grid but the visible property is set to false.)i want to retrieve the data from the grid.
pintoo
Hi Chithra! Where is your TextBox resides? Inner side or outer side of GridView?
"Save water,It's precious" :)
-
Hi Chithra! Where is your TextBox resides? Inner side or outer side of GridView?
"Save water,It's precious" :)
hey i got it..the text box was outside the grid only..actually i used a html input field and made that field in the grid hidden..iam giving the code here which i used. and to retrieve the value txt1.Text = ((HtmlInputHidden)GvPromotion.Rows[e.NewEditIndex].FindControl("DescHiddenValue")).Value;
pintoo
-
Hi Chithra! Where is your TextBox resides? Inner side or outer side of GridView?
"Save water,It's precious" :)
hey i got it..the text box was outside the grid only..actually i used a html input field and made that field in the grid hidden..iam giving the code here which i used. and to retrieve the value txt1.Text = ((HtmlInputHidden)GvPromotion.Rows[e.NewEditIndex].FindControl("DescHiddenValue")).Value; anyway thanx for sparing your time..
pintoo
-
hey i got it..the text box was outside the grid only..actually i used a html input field and made that field in the grid hidden..iam giving the code here which i used. and to retrieve the value txt1.Text = ((HtmlInputHidden)GvPromotion.Rows[e.NewEditIndex].FindControl("DescHiddenValue")).Value; anyway thanx for sparing your time..
pintoo
You are Welcome!...... :)
"Save water,It's precious" :)