我已經寫了下面的內容來顯示datagrid中的數據,並且插入新行,但是如何執行更新和刪除plss幫助這裏是我的代碼 using System; using System.Data; using System.Configuration;使用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;使用Telerik.Web.UI的 ; using System.Data.SqlClient;radgridview在asp.net中刪除更新
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; [email protected];";
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)
{
}
}
}