Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
网格视图中不同颜色的数据显示取决于asp.net中的文本_Asp.net - Fatal编程技术网

网格视图中不同颜色的数据显示取决于asp.net中的文本

网格视图中不同颜色的数据显示取决于asp.net中的文本,asp.net,Asp.net,我正在从sql server在Gridview中显示学生出勤情况。我选择apsent作为A,present作为P,leave作为L。现在我想在Gridview数据绑定中显示A为红色,P为绿色,而不是标题文本。怎么样。请帮帮我 <asp:GridView ID="studentGridView" runat="server" OnRowDataBound="studentGridView_RowDataBound"/> protected void studentGridVi

我正在从sql server在Gridview中显示学生出勤情况。我选择apsent作为A,present作为P,leave作为L。现在我想在Gridview数据绑定中显示A为红色,P为绿色,而不是标题文本。怎么样。请帮帮我


<asp:GridView ID="studentGridView" runat="server" OnRowDataBound="studentGridView_RowDataBound"/>    

protected void studentGridView_RowDataBound(Object sender,GridViewRowEventArgs e)
    {
        const int statusFieldIndex = 1;
        if (e.Row.Cells[statusFieldIndex].Text == "A")
        {
            e.Row.BackColor = Color.Red;
        }
        //etc
    }
受保护的void studentGridView_RowDataBound(对象发送方,GridViewRowEventArgs e) { const int statusFieldIndex=1;
if(e.Row.Cells[statusFieldIndex].Text==“A”) { e、 Row.BackColor=Color.Red; } //等 }

statusFieldIndex将设置为包含A、L、p等的字段的索引

受保护的无效studentGridView_RowDataBound(对象发送方,GridViewRowEventArgs e){const int statusFieldIndex=1;if(e.Row.Cells[statusFieldIndex].Text=“A”){e.Row.BackColor=Color.Red;}//etc}如果此文本中的(e.Row.Cells[statusFieldIndex].Text==“A”)与列标题文本进行比较,则statusFieldIndex将设置为包含A、L、P等的字段的索引。但我想比较本文中的绑定数据(A)(e.Row.Cells[statusFieldIndex].Text==“A”)与列标题文本。但是我想比较绑定数据(A)–e.Row.DataItem包含源数据