Hello,
I have a System.Windows.Forms.DataGrid which is bound to a DataSet
containing a table and columns such as user_id, user_firstname,
user_lastname, etc... How can I force the DataGrid component NOT to
display the user_id column without narrowing my sql query because the
program logic needs this column. I tried the following:
DataSet1.ReadXml('users.xml');
DataSet1.Tables['users'].Columns['user_id'].ColumnMapping :=
MappingType.Hidden;
This code works well and prevents the user_id column from being
displayed in the DataGrid. I can also access the values of the user_id
column programatically by calling:
string currentUserId =
DataSet1.Tables['users'].Rows[DataSet1.CurrentRowIndex].Item['user_id'].ToString();
The problem is when I call DataSet1.WriteXml('users.xml'); to save
back any changes to the underlying backend - the "user_id" attribute is
not persisted at all and the structure of the xml file is modified!!
Could you please help me with this issue?
Rakesh Rajan - 10 Dec 2004 04:25 GMT
Hi,
Columns set with MappingType.Hidden will not be written when you call
WriteXML.
Instead, try setting the GridColumStyle.Width to zero as specified in
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbts
kaddingdeletingorhidingcolumns.asp
HTH,
Rakesh Rajan
> Hello,
>
[quoted text clipped - 19 lines]
> not persisted at all and the structure of the xml file is modified!!
> Could you please help me with this issue?