0

将GridView绑定到DataTable时,如何改变BoundField显示的值

4

1 回答 1

1

一种方法是这样的:

<asp:CheckBox ID="CheckBox1" runat="server" 
Checked='<%# (((String)DataBinder.Eval(Container.DataItem, "Status")) == "O")?true:false %>' />

然后您可以控制后面的代码,例如:

protected void gvFiles_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        if (DataBinder.Eval(e.Row.DataItem, "LastUser").ToString() == "x")
        {
            TextBox txtId = gvFiles.FindControl("txtId") as TextBox;
            txtId.Text = "NA";
        }
    }

}
于 2009-07-15T03:45:11.707 回答