Wednesday, 8 October 2014

Add text in a Gridview using RowDatabound in ASP.NET using C#

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label l1 = (Label)e.Row.FindControl("Label5");
            if (!string.IsNullOrEmpty(l1.Text))
            {
                if (l1.Text != "300" && l1.Text != "450")
                {
                    e.Row.Cells[3].Text = "Rs. " + l1.Text + " per hour";
                    //e.Row[].Cells[3].Text = "Rs. " + l1.Text + " ";
                }
                else
                {
                    e.Row.Cells[3].Text = "Rs. " + l1.Text + " ";
                }
            }
        }
    }

No comments:

Post a Comment