Datagrid help

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

I have a datagrid and have a dataset for a data source in
the properties for the datagrid. I used the property
builder to set columns, and have a table set for the data
member. I also have a connection to an SQL database. For
the columns I am able to select those from the table and
they do show up in the design window. when I run the
application nothing shows up for the datagrid. If anyone
can help,Thanks Paul.
 
Paul said:
I have a datagrid and have a dataset for a data source in
the properties for the datagrid. I used the property
builder to set columns, and have a table set for the data
member. I also have a connection to an SQL database. For
the columns I am able to select those from the table and
they do show up in the design window. when I run the
application nothing shows up for the datagrid. If anyone
can help,Thanks Paul.

Did you remember to call .DataBind() on your grid? You have to tell it
when you are set to bind the data to the grid, by doing this call in
your code.
 
Hi thanks for the quick response. I have not added
anything in the code related to the datagrid. Where and
how do you call .DataBind() on your grid? Is this done in
the code with the page load at
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

End Sub
Thanks again, Paul.
 
Hi, I did not add anycode associated with the data grid as
I thought just by setting the properties it should
populate when you run the app. Do you know if you are
supposed to add code in the page load subroutine to get
the data to show up?

Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
 
Paul said:
Hi thanks for the quick response. I have not added
anything in the code related to the datagrid. Where and
how do you call .DataBind() on your grid? Is this done in
the code with the page load at
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

End Sub
Thanks again, Paul.

Yes, normally in your Page_Load. And you pry want to check IsPostBack
and bind only when it is not posting back (once)....forgot to mention a
couple of more details as well, you have to retrieve the data, the
wizards only setup the objects, queries, etc. before the page
loads...see this walkthrough from Microsoft

http://msdn.microsoft.com/library/d...throughdisplayingdataingridinwebformspage.asp
 
Ok, thanks this info looks very helpful.
-----Original Message-----


Yes, normally in your Page_Load. And you pry want to check IsPostBack
and bind only when it is not posting back (once)....forgot to mention a
couple of more details as well, you have to retrieve the data, the
wizards only setup the objects, queries, etc. before the page
loads...see this walkthrough from Microsoft

http://msdn.microsoft.com/library/default.asp? url=/library/en-
us/vbcon/html/vbwlkwalkthroughdisplayingdataingridinwebform
spage.asp
 
Back
Top