protected void btnedit_Click1(object sender, EventArgs e) { dt = (DataTable)ViewState["qualification"]; int Id; foreach (GridViewRow row in gvqualification.Rows) { RadioButton rb = (RadioButton)row.FindControl("rdoselect"); HiddenField HFI = (HiddenField)row.FindControl("autoid"); HiddenField HFE = (HiddenField)row.FindControl("qualificationid"); Label lbleducational = (Label)row.FindControl("lbgeducationallevel"); Label lblcollege = (Label)row.FindControl("lbgcollege"); Label lbluniversity = (Label)row.FindControl("lbguniversity"); Label lblspecialization = (Label)row.FindControl("lbgspecialization"); Label lblscore = (Label)row.FindControl("lbgscore"); Label lblstartyear = (Label)row.FindControl("lbgstartyear"); Label lblyearofcompletion = (Label)row.FindControl("lbgyearofcompletion"); Label lblstate = (Label)row.FindControl("lbgstate"); Label lblcountry = (Label)row.FindControl("lbgcountry"); if (rb.Checked) { Id = int.Parse(HFI.Value); hqualificationid.Value = HFE.Value; txteducationallevel.Text = lbleducational.Text; txtcollegename.Text = lblcollege.Text; txtuniversity.Text = lbluniversity.Text; txtspecialization.Text = lblspecialization.Text; txtscore.Text = lblscore.Text; ddlstartyear.Text = lblstartyear.Text; ddlyearofcompletion.Text = lblyearofcompletion.Text; txtstate.Text = lblstate.Text; txtcountry.Text = lblcountry.Text; dt = (DataTable)ViewState["qualification"]; int index = -1; try { foreach (DataRow dr in dt.Rows) { index = index + 1; if (dr["ID"].ToString() == Id.ToString()) { dt.Rows[index].Delete(); ViewState["qualification"] = dt; btnremove.Visible = false; } } } catch (Exception E) { dt = (DataTable)ViewState["qualification"]; gvqualification.DataSource = dt; gvqualification.DataBind(); } } } }
GridView имеет свойство "EmptyDataText", он устанавливает текст, если нет данных.
<asp:GridView ID="grid" runat="server" EmptyDataText="No Record Found!" > <column> --- </column> </asp:GridView>