Friday, February 12, 2010

ASP.Net GridView control question?

I have a gridview on an ASP.Net page and i want to pull data from a specified row/column and populate a text box?


Or if easier, can i just write a SQL command to query and return data to a textbox, using vb.net or javascript?


Thanks!ASP.Net GridView control question?
Yes.... U can write a query in two ways...





U can write it in your table adapter or can write it inside the Commandtext property of your dataset.





DO the necessary data connections for your grid and load the data access layer method for retriving data.





ex-





Dim productsAdapter As New NorthwindTableAdapters.ProductsTableAdap…


Dim products as Northwind.ProductsDataTable





products = productsAdapter.GetProducts()





For Each productRow As Northwind.ProductsRow In products


Response.Write(';Product: '; %26amp; productRow.ProductName %26amp; ';
';)


Next





visit


http://www.asp.net/learn/dataaccess/tuto…ASP.Net GridView control question?
you can use a sql command to get the data you need in a string format. You'll want to look up ExecuteScalar - it's a db call method that returns a string.





Setting up the text in the textbox would simply be:


Textbox.Text = DataResults;

No comments:

Post a Comment