Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi to all,

 

I have a DataSet which i populate it with all the information that exists in a table in my database.

 

I will bind that DataSet to a DataGrid to show the information but i don't what to show all columns that exists in the DataSet.

 

So how can i limit what appears in the datagrid?? do i have to make a new DataSet with only the information i want?

 

thx to all

Posted

You have to use a DataGridTableStyle. Set the MappingName of the table style to the name of the DataTable you want displayed in the grid. Create DataGridTextBoxColumn's for each column you would like to display in the grid. Set the MappingName to the name you gave each column in your DataTable. Add each DataGridTextBoxColumn to the DataGridTableStyle. Add the DataGridTableStyle to the DataGrid's TableStyles collection. If any of this isn't clear let me know. I'll give you some example code.

 

Todd

 

Todd

Posted

thx for the replys...

 

but i found a good solution to deal with the problem. here is what i do:

 

MyDataSet.Tables[0].Columns["Col1"].ColumnMapping = MappingType.Hidden;

MyDataSet.Tables[0].Columns["Col2"].ColumnMapping = MappingType.Hidden;

....

 

and i do this for all the columns i want to hide....and it works :D

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...