protected void grdvwSite_RowDataBound(Object sender, GridViewRowEventArgs e) { // if (e.Row.RowType == DataControlRowType.DataRow) { // Hndling GridView RowDataBound Event for Binding regionid to region name int regionid = Convert.ToInt16(e.Row.Cells[2].Text); // Calling function objRegion.Get_By_id() to get region name via region id objRegion = objRegion.Get_By_id(regionid); // Assign region name to particular cell of Grid e.Row.Cells[2].Text = objRegion.Regionname.ToString(); } }
//*Start* Code added by Shrikant protected void Regiongrdvw_RowUpdating(object sender, GridViewUpdateEventArgs e) { string name, desc, id; int Regionid = 0; int FlagRegion; int organizationId; objOrganization = objOrganization.Get_Organization(); organizationId = objOrganization.Orgid; clearControl(); name = ((TextBox)Regiongrdvw.Rows[e.RowIndex].Cells[1].Controls[0]).Text; desc = ((TextBox)Regiongrdvw.Rows[e.RowIndex].Cells[3].Controls[0]).Text; id = Convert.ToString(Regiongrdvw.Rows[e.RowIndex].Cells[0].Text); Regionid = Convert.ToInt16(id); Regionobj = Regionobj.Get_By_id(Regionid); if (Regionobj.Regionname == name) { Regionobj.Regionname = name; Regionobj.Description = desc; Regionobj.Update(); Regiongrdvw.EditIndex = -1; BindGrid(); lblerrmsg.Text = Resources.MessageResource.errupdate.ToString(); } else { FlagRegion = Regionobj.Get_By_RegionName(name, organizationId); if ((FlagRegion == 0) && (name != "")) { Regionobj.Regionname = name; Regionobj.Description = desc; Regionobj.Update(); Regiongrdvw.EditIndex = -1; BindGrid(); lblerrmsg.Text = Resources.MessageResource.errupdate.ToString(); } else if (name == "") { lblerrmsg.Text = Resources.MessageResource.errnotempty.ToString(); } else { Regiongrdvw.EditIndex = -1; BindGrid(); lblerrmsg.Text = Resources.MessageResource.errRegionExist.ToString(); } } }
public int Update_Region_mst_By_id(Region_mst objRegion) { return (int)ExecuteNonQuery(Sp_Region_Update, new object[] { objRegion.Regionname, objRegion.Regionid, objRegion.Orgid, objRegion.Description, objRegion.Createdatetime }); }
public int Insert_Region_mst(Region_mst objRegion) { return (int)ExecuteNonQuery(Sp_Region_Insert, new object[] { objRegion.Regionname, objRegion.Regionid, objRegion.Orgid, objRegion.Description, objRegion.Createdatetime }); }
public object GenerateRegion_mstObject(ref IDataReader returnData) { Region_mst obj = new Region_mst(); while (returnData.Read()) { DateTime Mydatetime = new DateTime(); obj.Regionid = (int)returnData["Regionid"]; obj.Regionname = (string)returnData["Regionname"]; obj.Description = (string)returnData["Description"]; Mydatetime = (DateTime)returnData["Createdatetime"]; obj.Createdatetime = Mydatetime.ToString(); } returnData.Close(); returnData.Dispose(); return obj; }
public CollectionBase GenerateRegion_mstCollection(ref IDataReader returnData) { BLLCollection<Region_mst> col = new BLLCollection<Region_mst>(); while (returnData.Read()) { DateTime Mydatetime = new DateTime(); Region_mst obj = new Region_mst(); obj.Regionid = (int)returnData["RegionId"]; obj.Regionname = (string)returnData["Regionname"]; obj.Description = (string)returnData["Description"]; obj.Orgid = (int)returnData["Orgid"]; Mydatetime = (DateTime)returnData["Createdatetime"]; obj.Createdatetime = Mydatetime.ToString(); col.Add(obj); } returnData.Close(); returnData.Dispose(); return col; }
//*Start* Code added by Shrikant protected void Regiongrdvw_RowUpdating(object sender, GridViewUpdateEventArgs e) { string name, desc, id; int Regionid = 0; int FlagRegion; int organizationId; objOrganization = objOrganization.Get_Organization(); organizationId=objOrganization.Orgid; clearControl(); name = ((TextBox)Regiongrdvw.Rows[e.RowIndex].Cells[1].Controls[0]).Text; desc = ((TextBox)Regiongrdvw.Rows[e.RowIndex].Cells[3].Controls[0]).Text; id = Convert.ToString(Regiongrdvw.Rows[e.RowIndex].Cells[0].Text); Regionid = Convert.ToInt16(id); Regionobj = Regionobj.Get_By_id(Regionid); if (Regionobj.Regionname == name) { Regionobj.Regionname = name; Regionobj.Description = desc; Regionobj.Update(); Regiongrdvw.EditIndex = -1; BindGrid(); lblerrmsg.Text = Resources.MessageResource.errupdate.ToString(); } else { FlagRegion = Regionobj.Get_By_RegionName(name, organizationId); if ((FlagRegion == 0)&&(name!="")) { Regionobj.Regionname = name; Regionobj.Description = desc; Regionobj.Update(); Regiongrdvw.EditIndex = -1; BindGrid(); lblerrmsg.Text = Resources.MessageResource.errupdate.ToString(); } else if(name=="") { lblerrmsg.Text = Resources.MessageResource.errnotempty.ToString(); } else { Regiongrdvw.EditIndex = -1; BindGrid(); lblerrmsg.Text = Resources.MessageResource.errRegionExist.ToString(); } } }