You must Sign In to post a response.
  • Category: .NET

    change gridview row color

    change gridview row color.
  • #272107
    protected void productsGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    // determine the value of the UnitsInStock field
    int unitsInStock =
    Convert.ToInt32(DataBinder.Eval(e.Row.DataItem,
    "strShift"));
    if (unitsInStock.ToString()=="Alarm");
    // color the background of the row yellow
    e.Row.BackColor = Color.Yellow;

  • #272156
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    // searching through the rows
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    bool isnew = (bool)DataBinder.Eval(e.Row.DataItem, "IsNew");
    if ( isnew ) e.Row.BackColor = Color.FromName("#FAF7DA"); // is a "new" row
    }
    }

  • #272157
    hi,

    Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)

    If e.Row.RowType = DataControlRowType.DataRow Then
    Dim lbl As Label = CType(e.Row.FindControl("lblPreis"), Label)
    If DataBinder.Eval(e.Row.DataItem, "unitprice") < 0D Then
    lbl.ForeColor = Drawing.Color.Red End If

    End If

    End Sub

    Hope this helps!

  • #272179
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    DataRowView test = (System.Data.DataRowView)e.Row.DataItem;
    bool actionPlanExists = SqlConvert.ToBoolean(test.Row[“ActionPlanExists"]);
    if (actionPlanExists == true)
    {
    e.Row.BackColor = System.Drawing.Color.Red;
    e.Row.ForeColor = System.Drawing.Color.White;
    }
    }
    }

  • #272188
    <asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound" >
    ...
    </asp:GridView>

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    // searching through the rows
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    bool isnew = (bool)DataBinder.Eval(e.Row.DataItem, "IsNew");
    if ( isnew ) e.Row.BackColor = Color.FromName("#FAF7DA"); // is a "new" row
    }
    }

  • #272224
    protected void productsGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    // determine the value of the UnitsInStock field
    int unitsInStock =
    Convert.ToInt32(DataBinder.Eval(e.Row.DataItem,
    "strShift"));
    if (unitsInStock.ToString()=="Alarm");
    // color the background of the row yellow
    e.Row.BackColor = Color.Yellow;


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.