Esempio n. 1
0
 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();
            }
        }
    }