473,387 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 6707
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

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

Similar topics

0
by: Ann Morris | last post by:
INTRODUCTION One of the most powerful aspects of .NET and Windows Forms is data binding. Data binding is the process of associating user interface (UI) elements with a data source to generate a...
1
by: J | last post by:
This works well for binding a Dataset (created from an XML file) to a DataGrid for the entire 'page' table. However I would like to only grab a few rows from the 'page' table (like: select id,...
5
by: Jason Huang | last post by:
Hi, Is it possible to bind DataReader to a DataGrid in C# windows form? And how? And can we update data in a DataSet by using the DataReader? Thanks for help. Jason
0
by: GrumpyDev | last post by:
Hi. My question is regarding binding a DataSet to a DataGrid. When I change Caption property of all column in my dataset and then bind dataset to a DataGrid, new caption aren't displayed in a grid...
2
by: Chris Kennedy | last post by:
I have two datagrids on a page. On the update event of the first I take some of the selected data, create a dataset and add it and then bind it to the second datagrid. If I hit update several...
2
by: Andrew Robinson | last post by:
Is there any way to accomplish two way data binding in a Details View with a DataSet or DataTable as the DataSource. All I want is to get an updated DataSet or DataTable back from the...
8
by: Richard L Rosenheim | last post by:
I have a dataset containing a parent table related to a child table. The child table contains an ID field (which is configured as autonumber in the datatable), the ID of the parent, plus some...
6
by: p.mc | last post by:
Hi all, I'm having major problems with a userControl which contains a datagrid. My problem concerns data binding. The Page_Load() procedure calls the DataBind procedure to bind the datagrid...
3
by: no | last post by:
Hi all, I have a dataset that contain 2 tables and a relationship between them (master detail). I bind this dataset to a form that include some textboxes that bind to the parent record, and a...
0
by: | last post by:
I have a question about spawning and displaying subordinate list controls within a list control. I'm also interested in feedback about the design of my search application. Lots of code is at the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.