Capturing SQL Recordset to Control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a SQL DataSource that returns: first name, last name, title, UserID.
I now want to capture each of these records and place them into their
corresponding textboxes on my webforms, how do I accomplish this.
thank you.
 
I have a SQL DataSource that returns: first name, last name, title, UserID.
I now want to capture each of these records and place them into their
corresponding textboxes on my webforms, how do I accomplish this.
thank you.

something like the following code

ASPX

ProductName = <asp:label id="lblProductName" runat="server" />
<asp:objectdatasource id="odsProducts" runat="server"
selectmethod="GetProductByProductID"
typename="NorthwindTableAdapters.ProductsTableAdapter">
<selectparameters>
<asp:parameter defaultvalue="1" name="ProductID" type="Int32" />
</selectparameters>
</asp:objectdatasource>

CODE-BEHIND

protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataView dv = (DataView)odsProducts.Select();

lblProductName.Text = dv[0]["ProductName"].ToString();
}
}
 
Alexey,
Will this work for Visual Web Developer Express? Im doing research on table
adapters and notice much of the objects in the instructions are not in the
menubars & tools. My apologies Im new to ASP.Net world. thanks.

Alexey Smirnov said:
I have a SQL DataSource that returns: first name, last name, title, UserID.
I now want to capture each of these records and place them into their
corresponding textboxes on my webforms, how do I accomplish this.
thank you.

something like the following code

ASPX

ProductName = <asp:label id="lblProductName" runat="server" />
<asp:objectdatasource id="odsProducts" runat="server"
selectmethod="GetProductByProductID"
typename="NorthwindTableAdapters.ProductsTableAdapter">
<selectparameters>
<asp:parameter defaultvalue="1" name="ProductID" type="Int32" />
</selectparameters>
</asp:objectdatasource>

CODE-BEHIND

protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataView dv = (DataView)odsProducts.Select();

lblProductName.Text = dv[0]["ProductName"].ToString();
}
}
 
Back
Top