4
Reply

If there is 0 value in gridviwe how to display in the form 'NR'

sagar Bhosale

sagar Bhosale

Jul 19 2011 8:01 AM
1.9k
My code is

protected void gwdSearchRating_RowDataBound(object sender, GridViewRowEventArgs e)
  {
  Image img;
  if (e.Row.RowType == DataControlRowType.DataRow)
  {
  Label lbl_rating = (Label)e.Row.FindControl("lbl_rating");
    if (lbl_rating.Text == "")  //what is condition here i write if there 0 value i get "NR"
  {
  lbl_rating.Text = "NR";
  } 

  int rating = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "rating"));
  for (int i = 0; i < rating; i++)
  {
  img = new Image();
  img.ImageUrl = "~/Images/Rating_star.gif";
  e.Row.Cells[1].Controls.Add(img);
  }

  }
  }

Please help me

Answers (4)