3
Answers

How to bind data to Text box

Ask a question
David

David

18y
2.6k
1

Hi,

I use a filter on a sqlDataSource which has uniq rows. I need to bind several fields of the result filtered row to textboxes. Here the code :

SqlDataSource dsPrev = (SqlDataSource)PreviousPage.FindControl("SqlDataSource1");
dsPrev.FilterExpression = "dr_id='" + id + "' ";
GridView gvTemp = new GridView();
gvTemp.DataSource = dsPrev;
gvTemp.DataBind();
TextBox1.Text = gvTemp.Rows[0].Cells[3].Text;

Is there a more professional way to do it ?

Thanks,

David


Answers (3)