radgridview delete update in asp.net

Posted by abhi on Stack Overflow See other posts from Stack Overflow or by abhi
Published on 2010-05-13T11:11:39Z Indexed on 2010/05/13 11:14 UTC
Read the original article Hit count: 264

Filed under:
|
|

i have written the follwing to display data from the datagrid and den insert new rows but how do i perform update and delete plss help here's my code using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using Telerik.Web.UI; using System.Data.SqlClient;

public partial class Default6 : System.Web.UI.Page { string strQry, strCon;

SqlDataAdapter da;
SqlConnection con;
DataSet ds;

protected void Page_Load(object sender, EventArgs e)
{
    strCon = "Data Source=MINETDEVDATA; Initial Catalog=ML_SuppliersProd; User Id=sa; Password=@MinetApps7;";
    con = new SqlConnection(strCon);
    strQry = "SELECT * FROM table1";
    da = new SqlDataAdapter(strQry, con);
    SqlCommandBuilder cmdbuild = new SqlCommandBuilder(da);
    ds = new DataSet();
    da.Fill(ds, "table1");
    RadGrid1.DataSource = ds.Tables["table1"];
    RadGrid1.DataBind();
    Label3.Visible = false;
    Label4.Visible = false;
    Label5.Visible = false;
    txtFname.Visible = false;
    txtLname.Visible = false;
    txtDesignation.Visible = false;

}
protected void Submit_Click(object sender, EventArgs e)
{
    Label3.Visible = true;
    Label4.Visible = true;
    Label5.Visible = true;
    txtFname.Visible = true;
    txtLname.Visible = true;
    txtDesignation.Visible = true;
}
protected void Button2_Click(object sender, EventArgs e)
{
    DataSet ds = new DataSet("EmployeeSet");
    da.Fill(ds, "table1");



    DataTable EmployeeTable = ds.Tables["table1"];
    DataRow row = EmployeeTable.NewRow();
    row["Fname"] = txtFname.Text.ToString();
    row["Lname"] = txtLname.Text.ToString();
    row["Designation"] = txtDesignation.Text.ToString();
    EmployeeTable.Rows.Add(row);
    da.Update(ds, "table1");
    //RadGrid1.DataSource = ds.Tables["table1"];
    //RadGrid1.DataBind();
    txtFname.Text = "";
    txtLname.Text = "";
    txtDesignation.Text = "";


}






protected void RadGrid1_DeleteCommand(object source, GridCommandEventArgs e)
{


    }
}

}

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql