How do i debug a datagrid problem ?

T

Tony Girgenti

Hello.

I'm developing and testing a web application using VS.NET 2003, VB, .NET
Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1 on a WIN XP Pro, SP2
computer. I'm using a web form.

I'm trying to display a datagrid on my web form using this code:
Me.tripsDataGrid.DataSource = Me.tripsDataSet
Me.tripsDataGrid.DataMember =
Me.tripsDataSet.tripsTable.ToString
Me.tripsDataGrid.DataBind()

It displays the DataGrid on the form with the column headers but no data
rows. The data is in the tripsTable rows because i can display them in the
debugger.

How do i debug this to figure out why it is not populating the datagrid ?

Any help would be gratefully appreciated.

Thanks,
Tony
 
B

Brian Foree

I don't know if this would make a difference, but everything looks OK in
your code with the possible exception of the following line:

Me.tripsDataGrid.DataMember = Me.tripsDataSet.tripsTable.ToString

I'd suggest replacing the right side of the expression with the name of the
table as a String, like so (I'm guessing at the name of the table within
your DataSet):

Me.tripsDataGrid.DataMember = "trips"

The reason I'm suggesting this is because I seem to remember a similar
problem that was related to the DataMember being set incorrectly.

You could also set a breakpoint on this line (without the modification), run
the app in Debug mode and see what "Me.tripsDataSet.tripsTable.ToString"
evaluates to at that point. I did notice that the ToString method of a
System.Data.DataTable returns "the TableName and DisplayExpression, if there
is one as a concatenated string", so one possibility is that there is a
DisplayExpression, which would cause problems when you assign the
DataMember.

If my suggestion works and you still want to assign the DataMember
dynamically, you could try Me.tripsDataSet.tripsTable.TableName, which
contains just the name of the table as a String.
 
T

Tony Girgenti

Hello Brian.

I tried all of your suggestions and nothing worked. However, i did notice
that the line "Me.tripsDataSet.tripsTable.TableName" does yield the correct
table name, so i will probably stay with that in my coding.

All i need to do now is figure out why the grid is empty.

Thanks,
Tony
 
B

Brian Foree

Are you loading the data into the table before you call the DataGrid's
DataBind method? I know you said that the data is in the tripsTable rows
because you can display them in the debugger, but did you check that just
before the DataBind call?
 
T

Tony Girgenti

Brian.

Yes. I just checked it again. Very strange. When i use this statement:
Me.tripsDataGrid.DataSource = Me.tripsDataSet

It display the empty grid with the column name across the top.

If i use this statement:
Me.tripsDataGrid.DataSource = Me.tripsDataSet.DataSetName

It displays the grid with one column named "Item" and puts the name of the
dataset under it one letter at a time like this:
t
r
i
p
s
D
S

Thanks,
Tony
 
T

Tony Girgenti

Hello Brian.

I deleted all my data controls and started over and created a new datagrid.
Now the grid displays on my web form filled with sample data, which is
something it was not doing before. I also noticed that it allows me to use
the property page for the datagrid to select the DataSource and DataMember
properties in the dropdown list fashion, another thing it was not doing
before.

But i'm still having the same problem. It displays the Datagrid headings
but not the data from the typed dataset. I also tried assigning the
datasource and datamemeber dynamically.

Do you have any other ideas of what to try ?

Thanks,
Tony
 

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,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top