![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
Hi Andrew, Welcome to the ASP.NET newsgroup. Regarding on the GridView control's RowUpdating event problem, it is the expected behavior because when we do not associate GridView(or other ASP.NET 2.0 databound control) with DataSource control, it won't automatically query and fill the parameters collection of the updating/deleting/... events. In such cases, we need to manually extract the field values from the Template control. Fortunately , ASP.NET 2.0 provide some good helper functions which ease our work on extracting field values from template databound control's datafields. e.g. the BoundField.ExtractValuesFromCell method: #BoundField.ExtractValuesFromCell Method http://msdn2.microsoft.com/en-us/lib...rols.boundfiel d.extractvaluesfromcell.aspx So in our GridView's RowUpdating event, we can manually query the data fields values (key , old values , new values...) from the corresponding cells. For example: ======================= protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { DataControlFieldCell cell = GridView1.Rows[e.RowIndex].Cells[0] as DataControlFieldCell; GridView1.Columns[0].ExtractValuesFromCell( e.Keys, cell, DataControlRowState.Normal, true); cell = GridView1.Rows[e.RowIndex].Cells[1] as DataControlFieldCell; GridView1.Columns[1].ExtractValuesFromCell( e.NewValues, cell, DataControlRowState.Edit, true); foreach (string key in e.Keys.Keys) { Response.Write("<br/>" + key + ": " + e.Keys[key]); } foreach (string key in e.NewValues.Keys) { Response.Write("<br/>" + key + ": " + e.NewValues[key]); } ................................... } ============================ Hope this helps. Regards, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.) |
#4
| |||
| |||
|
#5
| |||
| |||
|
#6
| |||
| |||
|
#7
| |||
| |||
|
#8
| |||
| |||
|
#9
| |||
| |||
|
#10
| |||
| |||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |