GridView를 DataTable에 바인딩 할 때 Boundfield가 표시하는 값을 어떻게 변경할 수 있습니까?

StackOverflow https://stackoverflow.com/questions/1063152

문제

GridView를 DataTable에 바인딩 할 때 Boundfield가 표시하는 값을 어떻게 변경할 수 있습니까?

도움이 되었습니까?

해결책

한 가지 방법은 다음과 같습니다.

<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";
        }
    }

}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top