protected void gvwtest_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Insert")
{
TextBox txtName = gvwtest.FooterRow.FindControl("txtName") as TextBox;
if (txtDepartmentName.Text == "")
{
DisplayMessage("Please Enter Name");
return;
}
//create object from Bussiness layer
Test_BL oTest_BL = new Test_BL();
int maxid = oTest_BL.GetMaxId() + 1;
lblMaxId.Text = maxid.ToString();
lblMaxId.Visible = false;
Test_Info oTest_Info = new Test_Info();
oTest_Info.Id = Convert.ToInt32(lblMaxId.Text);
oTest_Info.Name = txtName.Text.Trim();
int Result = oTest_BL.insertName(oTest_Info.Id,oTest_Info.Name);
if (Result == 1)
{
DisplayMessage("Saved successfully");
}
else
{
DisplayMessage("Same Name Already Exist");
}
//Filling gridview once again after insert
FillGrid();
}
}
No comments:
Post a Comment