我想在GridView的RowDataBound事件根据bit字段显示自定义的内容。如:姓名  性别
------------
aaaaa    男
bbbbb    女

解决方案 »

  1.   

    还是用模板列好。<asp:TemplateColumn HeaderText="性别">
          <ItemTemplate>
               <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Sex").ToString()=="1"?"男":"女" %>' ID="Label1">
               </asp:Label>
          </ItemTemplate>
    </asp:TemplateColumn>不知道在RowDataBound事件如何实现。
      

  2.   

    protected void btnDel_Click(object sender, EventArgs e)
     { 
    foreach (GridViewRow gvr in GridView1.Rows)
     { CheckBox ckb = (CheckBox)gvr.FindControl("CheckBox"); 
    if (ckb.Checked) {
     strDelId = GridView1.DataKeys[gvr.RowIndex].Value.ToString();
        } 
    }
    }