#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    1
    Rep Power
    0

    Gridview data display with different colors depends on text


    I have 3 radio buttons for a)New, b)Renew and c)All. where "All" lists all the Patients in the gridview. Where it includes new patients, renew patients, today's patients. i want to display 'New patients' in one color say 'yellow', 'Renew Patients' in 'Green' and 'Today's Patients' in 'Light Blue'. Is there is any way to implement gridview row data in different colors. So that it will be useful for the user to differentiate different patients.

    Following is the code how I did. But it takes only last color which is given (Lavendar). Records of dt should come in one color and records of dt1 should come in another color.

    protected void GridView1_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
    {
    int SelectedItem = Convert.ToInt32(RadButton.SelectedValue.ToString());
    if (e.Row.RowType == DataControlRowType.DataRow)
    {

    //string strValue = DataBinder.Eval(e.Row.DataItem, "KID_ID_NO_V").ToString();
    switch (SelectedItem)
    {
    case 1:
    e.Row.BackColor = System.Drawing.Color.Lavender;
    break;
    case 2:
    e.Row.BackColor = System.Drawing.Color.LavenderBlush;
    break;
    case 3:
    DataTable dt2 = new DataTable();
    dt = (DataTable)Session["New1"];
    dt1 = (DataTable)Session["Renew"];

    for (int i = 0; i < dt.Rows.Count; i++)
    {
    dt2.Merge(dt1);
    e.Row.BackColor = System.Drawing.Color.Honeydew;
    }
    for (int i = 0; i < dt1.Rows.Count; i++)
    {
    dt2.Merge(dt1);
    e.Row.BackColor = System.Drawing.Color.Lavender;
    }
    break;
    }
    }
    }
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    3
    Rep Power
    0
    I recently came across your article and have been reading along. I want to express my admiration of your writing skill and ability to make readers read from the beginning to the end. I would like to read newer posts and to share my thoughts with you.

IMN logo majestic logo threadwatch logo seochat tools logo