Beispiel #1
0
 // Handler grvwObj_RowDataBound handling GridView RowDataBound Event
 protected void grvwObj_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowState != DataControlRowState.Edit)
     {
         int   countryid;
         Label lblCountry = (Label)e.Row.FindControl("lblCountry");
         if (lblCountry != null)
         {
             countryid = Convert.ToInt32(lblCountry.Text);
             ViewState["countryid"] = lblCountry.Text;
             objCountry             = objCountry.Get_By_id(countryid);
             lblCountry.Text        = objCountry.Countryname.ToString();
         }
     }
     if (e.Row.RowState == DataControlRowState.Edit)
     {
         DropDownList dropCountry        = (DropDownList)e.Row.FindControl("dropCountry");
         BLLCollection <Country_mst> col = new BLLCollection <Country_mst>();
         col = objCountry.Get_All();
         dropCountry.DataSource     = col;
         dropCountry.DataTextField  = "countryname";
         dropCountry.DataValueField = "countryid";
         dropCountry.DataBind();
         dropCountry.SelectedValue = ViewState["countryid"].ToString();
     }
     if (e.Row.RowState == (System.Web.UI.WebControls.DataControlRowState.Alternate | System.Web.UI.WebControls.DataControlRowState.Edit))
     {
         DropDownList dropCountry        = (DropDownList)e.Row.FindControl("dropCountry");
         BLLCollection <Country_mst> col = new BLLCollection <Country_mst>();
         col = objCountry.Get_All();
         dropCountry.DataSource     = col;
         dropCountry.DataTextField  = "countryname";
         dropCountry.DataValueField = "countryid";
         dropCountry.DataBind();
         dropCountry.SelectedValue = ViewState["countryid"].ToString();
     }
 }
    // Handler grvwObj_RowDataBound handling GridView RowDataBound Event
    protected void grvwObj_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowState != DataControlRowState.Edit)
        {
            int countryid;
            Label lblCountry = (Label)e.Row.FindControl("lblCountry");
            if (lblCountry!=null)
            {
                countryid = Convert.ToInt16(lblCountry.Text);
                ViewState["countryid"] = lblCountry.Text;
                objCountry = objCountry.Get_By_id(countryid);
                lblCountry.Text = objCountry.Countryname.ToString();
            }
        }
        if (e.Row.RowState == DataControlRowState.Edit )
        {

            DropDownList dropCountry = (DropDownList)e.Row.FindControl("dropCountry");
            BLLCollection<Country_mst> col = new BLLCollection<Country_mst>();
            col = objCountry.Get_All();
            dropCountry.DataSource = col;
            dropCountry.DataTextField = "countryname";
            dropCountry.DataValueField = "countryid";
            dropCountry.DataBind();
            dropCountry.SelectedValue = ViewState["countryid"].ToString();
        }
        if (e.Row.RowState == (System.Web.UI.WebControls.DataControlRowState.Alternate | System.Web.UI.WebControls.DataControlRowState.Edit))
        {
            DropDownList dropCountry = (DropDownList)e.Row.FindControl("dropCountry");
            BLLCollection<Country_mst> col = new BLLCollection<Country_mst>();
            col = objCountry.Get_All();
            dropCountry.DataSource = col;
            dropCountry.DataTextField = "countryname";
            dropCountry.DataValueField = "countryid";
            dropCountry.DataBind();
            dropCountry.SelectedValue = ViewState["countryid"].ToString();
        }
    }
 public int Update_Country_mst_By_id(Country_mst objCountry)
 {
     return (int)ExecuteNonQuery(Sp_Country_Update, new object[] { objCountry.Countryname, objCountry.Countryid });
 }
 public int Insert_Country_mst(Country_mst objCountry)
 {
     return (int)ExecuteNonQuery(Sp_Country_Insert, new object[] { objCountry.Countryname, objCountry.Countryid });
 }
    public object GenerateCountry_mstObject(ref IDataReader returnData)
    {
        Country_mst obj = new Country_mst();
        while (returnData.Read())
        {

            obj.Countryid = (int)returnData["Countryid"];
            obj.Countryname = (string)returnData["Countryname"];

        }
        returnData.Close();
        returnData.Dispose();
        return obj;
    }
    public CollectionBase GenerateCountry_mstCollection(ref IDataReader returnData)
    {
        BLLCollection<Country_mst> col = new BLLCollection<Country_mst>();
        while (returnData.Read())
        {

            Country_mst obj = new Country_mst();
            obj.Countryid = (int)returnData["Countryid"];
            obj.Countryname = (string)returnData["Countryname"];

            col.Add(obj);
        }
        returnData.Close();
        returnData.Dispose();
        return col;
    }