4
Answers

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

sagar Bhosale

sagar Bhosale

13y
1.9k
1
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)