如何在.cs文件中编写用于编辑gridview的代码

问题描述:

我想在.cs文件中编写用于编辑的代码,我该怎么写
我在html中进行编码,因此在这种情况下不需要服务器端编码.

I would like to write the code for editing in .cs file how would i write that
I i do the coding in html it is working in that case no server side coding is required

SqlConnection con= new SqlConnection(@"Data Source=SPIL279\SQLEXPRESS;Initial Catalog=kamal_webapplicatins;Integrated Security=True;");
string @userid;
string @password;

protected void Page_Load(object sender, EventArgs e)
{
    string quary ="select UserId,Password from Regstration";
                //InsertCommand="INSERT INTO [Regstration] ([UserId], [User_First_Name], [User_Last_Name], [Password], [DateOfBirth], [Password_Question], [Password_Answer], [Mobile_no], [email]) VALUES (@UserId, @User_First_Name, @User_Last_Name, @Password, @DateOfBirth, @Password_Question, @Password_Answer, @Mobile_no, @email)"
    SqlDataAdapter da = new SqlDataAdapter(quary, con);
    DataSet ds = new DataSet();
    da.Fill(ds);
    gridview3.DataSource = ds.Tables[0];
    gridview3.DataBind();
}
protected void edit_click(object sender, EventArgs e)
{
    string update_quary = "update Regstration set password =@password where userud=@userid";
    SqlDataAdapter da = new SqlDataAdapter(update_quary, con);
    DataSet ds = new DataSet();
    da.Fill(ds);
}


/head>
  <removed id="form1" runat="server">
  <div>
  </div>
  <asp:removed id="gridview3" runat="server" xmlns:asp="#unknown">
    
  <asp:removed>
    
  <asp:removed id="btnEdit" runat="server" text="Edit" onclick="edit_click" causesvalidation="false" />
    
  </asp:removed>
  <asp:removed showeditbutton="true" showdeletebutton="true" showinsertbutton="true" /> 
  </asp:removed>

该站点上有许多文章可用于编辑gridview.
在ASP.NET中编辑各个GridView单元格 [可编辑的嵌套GridView(多合一) [使用键盘快捷键在ASP.NET 2.0 GridView控件中分页,选择,删除和编辑 [ ^ ]
看看他们.只需阅读已发表的文章,就能获得更多.
There are number of articles on this very site for editing gridview.
Edit Individual GridView Cells in ASP.NET[^]
Editable Nested GridView (All-in-One)[^]
Paging, Selecting, Deleting, and Editing in the ASP.NET 2.0 GridView Control with Keyboard Shortcuts[^]
Have a look at them. Can get more, just go through published articles.