解决方案 »

  1.   

    你将绑定在第0列的值的字段写在DataKeyField中
    <asp:DataGrid id="ListsGrid" runat="server" AllowSorting="True" AutoGenerateColumns="False" DataKeyField="ListID" OnEditCommand="ListsGrid_Edit" OnCancelCommand="ListsGrid_CancelEdit" OnUpdateCommand="ListsGrid_Update" OnDeleteCommand="ListsGrid_Delete" OnSortCommand="ListsGrid_Sort" Width="100%">
    <Columns>
    ..
    </Columns>在DataGrid中设置(DataKeyField="ListID") 是很重要的,需要有一个可以关系这个表格每条记录的主键,为什么不设DataKey呢?设置的时候是要绑定的一列字段名,不是具体值,系统会自动根据每条记录自动绑定的...DataGrid设计后,调协显示删除按钮的Cell
    <asp:ButtonColumn Text="<img border=0 Alt='Delete this list' src=./Images/Delete.gif>" CommandName="delete" />
    后台处理:
    protected void ListsGrid_Delete(object sender, DataGridCommandEventArgs e)
    //(int)ListsGrid.DataKeys[e.Item.ItemIndex]返回当前记录的DataKey(也就是ListID)值..
    此事件响应删除操作...
      

  2.   

    Label lbl = (Label)SelectedItem.Cells[3].Controls[0];
    string s = lbl.Text;