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

G

Guest

MY purpose is that develop a web form with textboxes to display database
contents.
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.

David

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>
 
J

Jeff Sheldon

David,

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.

-Jeff
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top