DataGrid in Compact Framework

G

Ghost

How do I bind DataGrid in Compact Framework to some dataset at runtime?
There is no SetDataBinding method:(.

And how can I see how many record is in DataSet?
 
P

Peter Foot [MVP]

You must bind the DataGrid to an individual table within the DataSet e.g.

[C#]
dataGrid1.DataSource = ds.Tables["TableName"];

[VB]
DataGrid1.DataSource = ds.Tables("TableName")

You can get the number of rows in the table using

[C#]
ds.Tables[0].Rows.Count;
ds.Tables["TableName"].Rows.Count;

[VB]
ds.Tables(0).Rows.Count
ds.Tables("TableName").Rows.Count

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups
 
G

Ghost

I do dataGrid1.DataSource = ds.Tables["TableName"]; but nothing is display
on grid.

Peter Foot said:
You must bind the DataGrid to an individual table within the DataSet e.g.

[C#]
dataGrid1.DataSource = ds.Tables["TableName"];

[VB]
DataGrid1.DataSource = ds.Tables("TableName")

You can get the number of rows in the table using

[C#]
ds.Tables[0].Rows.Count;
ds.Tables["TableName"].Rows.Count;

[VB]
ds.Tables(0).Rows.Count
ds.Tables("TableName").Rows.Count

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups

Ghost said:
How do I bind DataGrid in Compact Framework to some dataset at runtime?
There is no SetDataBinding method:(.

And how can I see how many record is in DataSet?
 
M

Mystic Mong

Hi,

I've listed below some code straight out of a working program we have. The
datagrid always displays the dataset contents fine. Check your code
carefully, you may be missing something basic.

Hope this helps.

C-Ya Aly


VB.NET:
Dim da As New SqlDataAdapter("", nConn)

Dim ds as New DataSet

da.SelectCommand.CommandText = "SELECT [BatchDate],[From],[To],[Quantity] "
_

& "FROM ho_processmaster WHERE ((
Code:
 = @Barcode) OR " _

& "([Code] = @Zipcode)) ORDER BY [BatchDate] Desc"

da.SelectCommand.Parameters.Add("@Barcode", Barcode)

da.SelectCommand.Parameters.Add("@Zipcode", lblZipcode.Text)

da.Fill(ds, "transtrack")

dgTransTrack.DataSource = ds.Tables("transtrack")





[QUOTE="Ghost"]
I do dataGrid1.DataSource = ds.Tables["TableName"]; but nothing is display
on grid.

[QUOTE="Peter Foot"]
You must bind the DataGrid to an individual table within the DataSet e.g.

[C#]
dataGrid1.DataSource = ds.Tables["TableName"];

[VB]
DataGrid1.DataSource = ds.Tables("TableName")

You can get the number of rows in the table using

[C#]
ds.Tables[0].Rows.Count;
ds.Tables["TableName"].Rows.Count;

[VB]
ds.Tables(0).Rows.Count
ds.Tables("TableName").Rows.Count

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups?  Let us know!
https://www.windowsembeddedeval.com/community/newsgroups

[QUOTE="Ghost"]
How do I bind DataGrid in Compact Framework to some dataset at runtime?
There is no SetDataBinding method:(.

And how can I see how many record is in DataSet?
[/QUOTE]
[/QUOTE]
[/QUOTE]
 
P

Peter Foot [MVP]

Things to check are that the dataset object to see if it is actually
populated and what tables it contains. Note you can also reference the
tables by index e.g.

dataGrid1.DataSource = ds.Tables[0];

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups

Ghost said:
I do dataGrid1.DataSource = ds.Tables["TableName"]; but nothing is display
on grid.

Peter Foot said:
You must bind the DataGrid to an individual table within the DataSet e.g.

[C#]
dataGrid1.DataSource = ds.Tables["TableName"];

[VB]
DataGrid1.DataSource = ds.Tables("TableName")

You can get the number of rows in the table using

[C#]
ds.Tables[0].Rows.Count;
ds.Tables["TableName"].Rows.Count;

[VB]
ds.Tables(0).Rows.Count
ds.Tables("TableName").Rows.Count

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups

Ghost said:
How do I bind DataGrid in Compact Framework to some dataset at runtime?
There is no SetDataBinding method:(.

And how can I see how many record is in DataSet?
 

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

Top