New record when using data binding

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

Guest

Hi,

I am somewhat confused as to how I can levarage Data Binding and data adapters with web forms.

I think I figured out the update part, but when I want to start with a brand new record, my data binding fails with "Index 0, or not non-negative" error.

I created a data adapter that autogenerated statements for SELECT, UPDATE and INSERT.

I also have a web form with a number of data bound elements such as:



<asp:textbox id=txtFirstName runat="server" Text='<%# DataBinder.Eval(DsClient1, "Tables[Client].DefaultView.[0].FirstName") %>'></asp:textbox><asp:textbox id=txtLastName runat="server" Text='<%# DataBinder.Eval(DsClient1, "Tables[Client].DefaultView.[0].LastName") %>'></asp:textbox>



If I want to start with a new record, what code shall I put in the Page_Load in order for these data-bindings to work?

Thanks.

Zhenya
http://www.rusmex.com
 
Hi,

The best thing is to have a look at the Quick starts samples that shipped
with the Framework. Here is a link:

Server-Side Data Access
http://samples.gotdotnet.com/quickstart/aspplus/doc/webdataaccess.aspx

There you should have several links to accomplish the following tasks:
Introduction to Server-Side Data
Connections, Commands, and DataSets
Accessing SQL-based Data
Binding SQL Data to a DataGrid
Performing a Parameterized Select
Inserting Data in a SQL Database ==> you need to look at this sample
Updating Data in a SQL Database
Deleting Data in a SQL Database
Sorting Data from a SQL Database
Working with Master-Detail Relationships
Writing and Using Stored Procedures
Accessing XML-based Data
Section Summary

Also for any specific ASP.NET question, you may want to use the ASPNET
Newsgroup instead. This NG is for ADO>NET specific questions.

I hope this helps!

Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2002 Microsoft Corporation. All rights
reserved

Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.
 
Back
Top