List Info

Thread: C-Sharp (C#) Group: Selecting from datagrid




C-Sharp (C#) Group: Selecting from datagrid
user name
2006-03-05 20:03:32
I have a (very simple) problem that I just can not solve:

I am populating a datagrid from SQL server using a Dataset.
The table
in question uses an Identity row, which increments by one
for every new
insert.

When I delete an entry, my usual code, which goes

"SELECT * FROM table WHERE ID = ID-1"
da.SelectCommand.parameters.add( ID, SqlDbType.int);
da.SelectCommand.parameters[ID].value =
datagrid.selectedIndex;

no longer works, as there are gaps in the identity column.

At the moment, the only solution I have is to select the
entire table
into a temproray table with a new rownumber( which will have
no gaps),
and work with the rownumber instead. Once the selected row
is in my
webpage, the temporary table is dropped, and recreated
everytime a
selection is made from the datagrid

this is obviously less than elegant and I need to finish
this soon.
What did I overlook?

Any pointers are greatly appreciated as this is driving me
around the
bend by now.

Sven


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at http://groups.
google.com/group/C_Sharp
-~----------~----~----~----~------~----~------~--~---

C-Sharp (C#) Group: Re: Selecting from datagrid
user name
2006-03-06 06:50:19
Hi,
I think you can solve this prob in a better way.
Once you get the selected index from the grid, you can get
the
corresponding row from your dataset (i.e.
dataTable.Rows[selectedIndex]) to which your gridis data
bound.
>From the dataset you can get the identity value.
Hope this may solve your problem.
Check it out.
Regards,
Arindam Sinha


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at http://groups.
google.com/group/C_Sharp
-~----------~----~----~----~------~----~------~--~---

C-Sharp (C#) Group: Re: Selecting from datagrid
user name
2006-03-06 11:11:21
arindam, thank you so much. I never even thought of that.
Works a treat!


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at http://groups.
google.com/group/C_Sharp
-~----------~----~----~----~------~----~------~--~---

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )