GridView를 DataTable에 바인딩 할 때 Boundfield가 표시하는 값을 어떻게 변경할 수 있습니까?
-
21-08-2019 - |
문제
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";
}
}
}
제휴하지 않습니다 StackOverflow