Tuesday, March 27, 2012

Binding a Text Box to a datasoure - Please help

I have search for answers to the all over google and every thing I have found so far did not work for some reason or anothr. .

Here is what I am looking for I am codeing in Visual Studio using C#. I have been able to crate a connection and create taxt boxes with a submit button that when it is presed enters data in to a database (Sql server) what I have been unable to do is:

1. Display data in a text box.

2. Update data

3. create buttons to navagate through fields.

I know I can do this with the gridview or datagrid but in really need a custome form for what I am doing.

Hello,

You can use a Sqldatasource to do insert, update and delete for your textboxes. You can read the data from datasource through a datareader object and bind the data you your textboxes manually. For example, txtComments.Text =Convert.ToString(dReader["Comments"]).

You can call Sqldatsource.update() to update your form data when your tesxboxes' values have been changed.

You can create a linkbutton to send in some sort of id to the page on its click event to retrieve data for these textboxes.

Or you can do everything from code behind as in ASP.NET 1.X programmatically.

If you have more questions, please post back.

No comments:

Post a Comment