admdev
April 1st, 2009, 01:43 PM
I have a list of 12 text boxes laid out in three rows (4 boxes per row). Each of these rows represents a record in SQL. Now what I need to do is select the records in SQL and populate them in the text boxes. How do I go through the retrieved records and assign them to the corresponding boxes?
what I need to do.
SQL fileds
field1, field2, field3, field4
First SQL record populates this TextBox1=field1------TextBox2=field2------TextBox3=field3-----TextBox4=field4
Second SQL record populates this TextBox5=field1------TextBox6=field2------TextBox7=field3-----TextBox8=field4
And so on......
Below is the code I am Using
SqlDataAdapter adapt = new SqlDataAdapter(
"Select * from table where id=" + refid + "order by this" , SqlConnstring);
DataSet dsdata = new DataSet();
//Create a table based on the query result
adapt.TableMappings.Add("Table", "dsdata");
adapt.Fill(dsdata);
System.Data.DataTable dtdata= dsdata.Tables["dsdata"];
foreach (DataRow row in dtdata.Rows)
{
First SQL record TextBox1=field1------TextBox2=field2------TextBox3=field3-----TextBox4=field4
Second SQL record TextBox5=field1------TextBox6=field2------TextBox7=field3-----TextBox8=field4
}
Thanks in advance.
what I need to do.
SQL fileds
field1, field2, field3, field4
First SQL record populates this TextBox1=field1------TextBox2=field2------TextBox3=field3-----TextBox4=field4
Second SQL record populates this TextBox5=field1------TextBox6=field2------TextBox7=field3-----TextBox8=field4
And so on......
Below is the code I am Using
SqlDataAdapter adapt = new SqlDataAdapter(
"Select * from table where id=" + refid + "order by this" , SqlConnstring);
DataSet dsdata = new DataSet();
//Create a table based on the query result
adapt.TableMappings.Add("Table", "dsdata");
adapt.Fill(dsdata);
System.Data.DataTable dtdata= dsdata.Tables["dsdata"];
foreach (DataRow row in dtdata.Rows)
{
First SQL record TextBox1=field1------TextBox2=field2------TextBox3=field3-----TextBox4=field4
Second SQL record TextBox5=field1------TextBox6=field2------TextBox7=field3-----TextBox8=field4
}
Thanks in advance.