Adding RowID when linking a datatable to a datagrid
Posted on 2005-03-07
Im almost a newbie in .NET, i´ve been learning & developing on it since 2 weeks ago and now i cant solve a problem which I need to solve urgently, hope any of you can help me with this.
I have a DataTable on my codebehind which returns an undefined number of columns, depending on the result of a query. One of these columns (the last one, index "N", column id called "ID") has a value that i want to use as the "id" for each row generated when i bind it to a datagrid. I also want that columnd to be hidden in the datagrid. As a example
If my DataTable Table1 is like this:
col1 col2 col3... colID
a b c id7
when i bind Table1 to Datagrid1 I should see on screen something like this:
col1 col2 col3
a b c
and the id for that row should have the next <tr id="id7"><td>a</td><td>b</td><td>c</td></tr>
and it would be even better if i could add a style tag for that tr too from the codebehind.
Thanks in advance