How to identify each row in a Datagrid with no primary id?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I've worked with C# for 5 months fixing bugs for appl. done by other
programmers. I'm just writing a small C# application by myself for the first
time. The database is Access 2000. I've set up the OleConnection and
selected the table that I want as a data source for the grid. My quesiton
is, how can I display all columns except the primary key column whis is just
an ID auto-generated by Access and has no meaning to the user, (I know I can
just not select the column in my query ) but I don't inlcude that ID column
then how I can correctly identify the record (row)?
Thanks, Alpha
 
Alpha,

You can select the id into your data set, you just dont have to show it.
What you want to do is check the TableStyles exposed by the DataGrid, which
in turn exposes ColumnStyles. All you have to do is remove the column style
for the primary key column, and it won't be displayed (even though it will
still be in the data set).

Hope this helps.
 
Thank you for your reply. I did find the tablestyle and the ColumnStyle in
the datagrid's property window. But They're both blank so I don't know what
do you mean to remove it. I tried adding each of those item but I'm still
not seeing the column names for the table.

Thanks, Alpha

Nicholas Paldino said:
Alpha,

You can select the id into your data set, you just dont have to show it.
What you want to do is check the TableStyles exposed by the DataGrid, which
in turn exposes ColumnStyles. All you have to do is remove the column style
for the primary key column, and it won't be displayed (even though it will
still be in the data set).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Alpha said:
Hi, I've worked with C# for 5 months fixing bugs for appl. done by other
programmers. I'm just writing a small C# application by myself for the
first
time. The database is Access 2000. I've set up the OleConnection and
selected the table that I want as a data source for the grid. My quesiton
is, how can I display all columns except the primary key column whis is
just
an ID auto-generated by Access and has no meaning to the user, (I know I
can
just not select the column in my query ) but I don't inlcude that ID
column
then how I can correctly identify the record (row)?
Thanks, Alpha
 
Set the column visible property to false i.e.
<Columns>
<asp:TemplateColumn HeaderText="Id" Visible="false">



Alpha said:
Thank you for your reply. I did find the tablestyle and the ColumnStyle in
the datagrid's property window. But They're both blank so I don't know what
do you mean to remove it. I tried adding each of those item but I'm still
not seeing the column names for the table.

Thanks, Alpha

Nicholas Paldino said:
Alpha,

You can select the id into your data set, you just dont have to show it.
What you want to do is check the TableStyles exposed by the DataGrid, which
in turn exposes ColumnStyles. All you have to do is remove the column style
for the primary key column, and it won't be displayed (even though it will
still be in the data set).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Alpha said:
Hi, I've worked with C# for 5 months fixing bugs for appl. done by other
programmers. I'm just writing a small C# application by myself for the
first
time. The database is Access 2000. I've set up the OleConnection and
selected the table that I want as a data source for the grid. My quesiton
is, how can I display all columns except the primary key column whis is
just
an ID auto-generated by Access and has no meaning to the user, (I know I
can
just not select the column in my query ) but I don't inlcude that ID
column
then how I can correctly identify the record (row)?
Thanks, Alpha
 
thanks everyone for your input. I think I got it now.


sakieboy said:
Set the column visible property to false i.e.
<Columns>
<asp:TemplateColumn HeaderText="Id" Visible="false">



Alpha said:
Thank you for your reply. I did find the tablestyle and the ColumnStyle in
the datagrid's property window. But They're both blank so I don't know what
do you mean to remove it. I tried adding each of those item but I'm still
not seeing the column names for the table.

Thanks, Alpha

Nicholas Paldino said:
Alpha,

You can select the id into your data set, you just dont have to show it.
What you want to do is check the TableStyles exposed by the DataGrid, which
in turn exposes ColumnStyles. All you have to do is remove the column style
for the primary key column, and it won't be displayed (even though it will
still be in the data set).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi, I've worked with C# for 5 months fixing bugs for appl. done by other
programmers. I'm just writing a small C# application by myself for the
first
time. The database is Access 2000. I've set up the OleConnection and
selected the table that I want as a data source for the grid. My quesiton
is, how can I display all columns except the primary key column whis is
just
an ID auto-generated by Access and has no meaning to the user, (I know I
can
just not select the column in my query ) but I don't inlcude that ID
column
then how I can correctly identify the record (row)?
Thanks, Alpha
 
Back
Top