How to display data in Textboxes using DataSet

Platform: ASP.NET| Category: TextBox

Product ID : <asp:TextBox id='TextBox1' style='Z-INDEX: 101; LEFT: 80px; POSITION: absolute; TOP: 64px' runat='server'></asp:TextBox>
Product Name:<asp:TextBox id='TextBox2' style='Z-INDEX: 102; LEFT: 80px; POSITION: absolute; TOP: 112px' runat='server'></asp:TextBox>

VB.NET


’Populate the DataSet
’...

’Display in TextBoxes using Column Name
TextBox1.Text = ds.Tables (0).Rows(0)('ProductId').ToString ();
TextBox2.Text =ds.Tables (0).Rows(0)('ProductName').ToString (); 

’Display in TextBoxes using Column Index
TextBox1.Text = ds.Tables (0).Rows(0)(0).ToString ();
TextBox2.Text =ds.Tables (0).Rows(0)(1).ToString (); 

C#


//Populate the DataSet
//...

//Display in TextBoxes using Column Name
TextBox1.Text = ds.Tables [0].Rows[0]['ProductId'].ToString ();
TextBox2.Text =ds.Tables [0].Rows[0]['ProductName'].ToString (); 

//Display in TextBoxes using Column Index
TextBox1.Text = ds.Tables [0].Rows[0][0].ToString ();
TextBox2.Text =ds.Tables [0].Rows[0][1].ToString (); 

Share with