datalist的 datalist_ItemCommand 得到主键:datalist.DataKeys[e.Item.ItemIndex];
 RadioButtonList得到绑定的Value RadioButtonList.SelectedValues;
 dropdownlist得到主键:int id2=Convert.ToInt32(BranchDrop.SelectedValue);id = Convert.ToInt32(BranchDrop.SelectedItem.Value);
gridview(RowDeleting):  int id =Convert.ToInt32(gridview1.DataKeys[e.RowIndex].Value.ToString());

gridview1_RowEditing:  id2 = Convert.ToInt32(gridview1.DataKeys[e.NewEditIndex].Value.ToString());

gridview(rowcommand)在GridView的DataKey属性上加上你所绑定数据的主键字段名,即可
如果你现在在Gridview1_RowDataBound(object sender, GridViewRowEventArgs e)事件中获取主键,那么:Gridview1.DataKeys[e.Row.RowIndex][0]。
如果你在Gridview1_RowCommand事件中获取主键,那么:Gridview1.DataKeys[Convert.ToInt32(e.CommandArgument)][0]


datagrid_itemcommand: Dim ID As String = Me.datagrid1.dataKeys(e.item.itemIndex).toString() 




 
        

 

posted on 2007-11-13 19:39  力-点滴  阅读(367)  评论(0编辑  收藏  举报