Data binding at design time. How to work with them. I got error me



MY purpose is that develop a web form with textboxes to display database
In design time, I follow the .Net document and click data binding property
field in each TextBox, select the corresponding colunm name of database table
to each textbox.

In the Page_Load procedure, I type me.databind().
Compiling is OK. When I run it, I got the following error message.
Did I do any thing wrong? How to do it?

Thank you for your help.


System.IndexOutOfRangeException: Index 0 is not non-negative and below total
rows count.

Source Error:

Line 11: <body MS_POSITIONING="GridLayout">
Line 12: <form id="Form1" method="post" runat="server">
Line 13: <asp:TextBox id="txtFirstName" style="Z-INDEX: 101; LEFT: 216px;
POSITION: absolute; TOP: 184px"
Line 14: runat="server" Width="200px" Text='<%#
DataBinder.Eval(dsPatients, "Tables[Patients].DefaultView.[0].FirstName") %>'>
Line 15: </asp:TextBox>



Jeff Sheldon


I'm not sure what database type you're using, but you'll want to double
check to make sure whatever method you're using (Query or Stored Procedure)
is actually returning data. You have it hard coded to put data from row 0
into the textbox.
I wouldn't suggest ever hardcoding a specific row's value to a field unless
that page will always return a single row no matter what.

Either way, double check your data, that seems to be the culprit.


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question