Reputation: 2393
I using the Ultrawebgrid- Update event::
protected void UltraWebGrid1_UpdateRow(object sender, RowEventArgs e)
so, I want to update the row(updated in the grid) in the datatable (inside a dataset)
The datatable doesn't hav any primary key too.. How can i find any row in such datatable?
for e.g. i can go for
UltraGridRow oldrow = (UltraGridRow) e.Data;
now, how can i find the row (in the datatable inside a dataset) which is same as the oldrow
so that i can update it in the dataset?
The datatable does not have any primary key
Upvotes: 1
Views: 3623
Reputation: 43217
In this case you will need to use LinqToDataSets, if you do not wish to iterate through all rows. You can find Examples for LinqToDataSet here and here.
LinkText 1: http://msdn.microsoft.com/en-us/vbasic/bb688086.aspx
LinkText 2: http://msdn.microsoft.com/en-us/library/bb386977.aspx
Upvotes: 0
Reputation: 135395
You need to have some way to uniquely identify a row in the database table. Normally, a database table will have a field or fields that serve this purpose by acting as a primary key. From what you are saying, it sounds like the table doesn't have a primary key. Nevertheless, there needs to be some combination of data that can be used to act like a primary key.
For example, the table might hold user information, and by combining hair colour, height, weight, address and age this could be sufficient to uniquely identify a user. Why you would want to do this is a little confusing to me, but we can assume you have a good reason for wanting to do this. Having formulated this combination, you need to put those guys into the where
clause of your SQL UPDATE statement to identify the row you want to update:
UPDATE TABLE_WITH_NO_PRIMARY_KEY SET NAME = 'Bobby Tables'
WHERE HAIR_COLOUR = 'RED' AND HEIGHT = '215' AND SO ON
The risk with doing this is you may run into a situation where more than one user have the same identifying features (maybe they are twins?) so the update statement will update both rows instead of only one.
Upvotes: 1