471,089 Members | 1,768 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,089 software developers and data experts.

Binding from Dataset to Datagrid

Hi,
I know binding to datagrid but I don't know to show some coloumns.
Example:
Dim adopter As New OleDbDataAdapter("select * from IPSAVE", baglanti)
Dim ds As DataSet = New DataSet
adopter.Fill(ds, "IP")
DataGrid1.DataSource = ds.Tables("IP")

But I don't want to change OleDbDataAdapter("select * from IPSAVE", baglanti)
Wiil I bind Some coloumns to datagrid.Can I change DataGrid1.DataSource = ds.Tables("IP")
Oct 9 '06 #1
4 6593
radcaesar
759 Expert 512MB
Yup U Can,

dsSAT.Tables["Transactions"].Columns.Add("Balance Amount", typeof(Double));
dsSAT.Tables["Transactions"].Columns["Balance Amount"].Expression = "[Gross Amount] - [Amount Received]";
dgSAT.DataSource =dsSAT.Tables[0];

;)


Hi,
I know binding to datagrid but I don't know to show some coloumns.
Example:
Dim adopter As New OleDbDataAdapter("select * from IPSAVE", baglanti)
Dim ds As DataSet = New DataSet
adopter.Fill(ds, "IP")
DataGrid1.DataSource = ds.Tables("IP")

But I don't want to change OleDbDataAdapter("select * from IPSAVE", baglanti)
Wiil I bind Some coloumns to datagrid.Can I change DataGrid1.DataSource = ds.Tables("IP")
Oct 9 '06 #2
Yup U Can,

dsSAT.Tables["Transactions"].Columns.Add("Balance Amount", typeof(Double));
dsSAT.Tables["Transactions"].Columns["Balance Amount"].Expression = "[Gross Amount] - [Amount Received]";
dgSAT.DataSource =dsSAT.Tables[0];

;)
I don't want to use some Oledbadopter's field(Select * from IPSAVE) .I don't want to show eaxample:"IP","SubnetMask" ....fields. I want to show "Name" field only in Datagrid . I didn't understand your solution.
Oct 10 '06 #3
You need to set up a DataGridTableStyle object on the datagrid. This object contains a DataGridColumnStyles collection, where you can define which columns will be shown. It is a bit onerous to set up, but pretty nice once it is. This enables your bound dataset to not have to be limited to the 1 column - the dataset can contain all colums, but your datagrid.datagridtablestyle object defines what colums to show. In your case you would only add 1 datagridcolumn to your datagridcolumn styles. You can set these up at runtime or at design time - easier at design time if you do it there.
Oct 10 '06 #4
You need to set up a DataGridTableStyle object on the datagrid. This object contains a DataGridColumnStyles collection, where you can define which columns will be shown. It is a bit onerous to set up, but pretty nice once it is. This enables your bound dataset to not have to be limited to the 1 column - the dataset can contain all colums, but your datagrid.datagridtablestyle object defines what colums to show. In your case you would only add 1 datagridcolumn to your datagridcolumn styles. You can set these up at runtime or at design time - easier at design time if you do it there.
Thanks your solution
Oct 11 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by GrumpyDev | last post: by
2 posts views Thread by Chris Kennedy | last post: by
2 posts views Thread by Andrew Robinson | last post: by
6 posts views Thread by p.mc | last post: by
3 posts views Thread by no | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.