gridview problem
-
Hi, I m working with asp.net 2.0. I set the GridView.DataKeys as ID. When I click on Update button. the updating event is raised. But in the e.Keys/NewValues/OldValues there is always 0. But I get the rowindex of hte row i edited. I think i didn't set any property of gridview. thats why i don't get value in e.NewValues Property Please help
-
Hi, I m working with asp.net 2.0. I set the GridView.DataKeys as ID. When I click on Update button. the updating event is raised. But in the e.Keys/NewValues/OldValues there is always 0. But I get the rowindex of hte row i edited. I think i didn't set any property of gridview. thats why i don't get value in e.NewValues Property Please help
Since I don't see your sample code, so IMO you may want to check a couple of properties: + The DataKeyNames property of the GridView control. + Do you use the BoundField or TemplateField with the data binding expression in the GridView control? If you use the expression, make sure it support two-way data binding. + Do you any datasource control with the GridControl? If yes, check the
ConflictDetection
property. You can see more details in MSDN[^] -
Since I don't see your sample code, so IMO you may want to check a couple of properties: + The DataKeyNames property of the GridView control. + Do you use the BoundField or TemplateField with the data binding expression in the GridView control? If you use the expression, make sure it support two-way data binding. + Do you any datasource control with the GridControl? If yes, check the
ConflictDetection
property. You can see more details in MSDN[^]My problem was i didn't attached an objectdatasource to the gridview. I was only getting RowIndex in the RowUpdating event. As i was not able to get the newValues,oldValues/Keys, I attached an objectdatasource(which is attached .dll file) to the gridview control. Now when i click on update link on the gridview, I get the newValues,oldValues/Keys. If i want to get access to newValues,oldValues/Keys in a RowUpdating event of a gridview/detailsview, do i have to always assign an objectdatasource.
-
My problem was i didn't attached an objectdatasource to the gridview. I was only getting RowIndex in the RowUpdating event. As i was not able to get the newValues,oldValues/Keys, I attached an objectdatasource(which is attached .dll file) to the gridview control. Now when i click on update link on the gridview, I get the newValues,oldValues/Keys. If i want to get access to newValues,oldValues/Keys in a RowUpdating event of a gridview/detailsview, do i have to always assign an objectdatasource.
sohne wrote:
If i want to get access to newValues,oldValues/Keys in a RowUpdating event of a gridview/detailsview, do i have to always assign an objectdatasource.
Yes, you do. If you don't specify the datasource in the
DataSourceID
property of the control, you only have the row index value in the event data argumentGridViewUpdateEventArgs
.