2011-01-21 110 views
0

在ASP.NET Web表單有一個ASP.NET GridView的經由對象數據源連接到一個C#類通行證密鑰

我有設置爲在一個DataKeyName的ID格。如何在更新網格時將此內容傳遞給C#類?

+0

我還沒有使用asp.net winforms一段時間,但是,從內存中,你應該能夠從事件參數獲取信息適當的事件 – Andrew 2011-01-21 20:20:49

回答

0

其實數據鍵名由數據網格自動傳遞給對象數據源。

0

可以拿起網格數據的鍵名當前行網格行中更新事件

protected void gvSearchResults_RowUpdating(object sender, GridViewUpdateEventArgs e) 
    { 
    //get handle on current grid row 
    DataKey keys = gvSearchResults.DataKeys[e.RowIndex]; 
    customerId= GeneralUtils.GetIntegerKeyValue(keys, "customerID"); 
    } 

然後使用對象的數據源將其傳遞給C#類更新事件

protected void odsHauliers_Updating(object sender, ObjectDataSourceMethodEventArgs e) 
    { 

    e.InputParameters["customerID"] = this.customerID; 
    }