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 has property "EmptyDataText" it set the text if no data.
<asp:GridView ID="grid" runat="server" EmptyDataText="No Record Found!" >
<column> --- </column>
</asp:GridView>
精彩评论