asp.net 编辑gridview的小例子_实用技巧

编辑gridview例子,完整代码如下。

复制代码 代码如下:

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
     {
         GridView1.EditIndex = e.NewEditIndex;
         BingGrid();
     }
     protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
     {
         GridView1.EditIndex = -1;
         BingGrid();
     }
     protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
     {
         try
         {
             GridViewRow row = GridView1.Rows[e.RowIndex];
             string TXB_FORUMNAME = ((TextBox)row.FindControl("TXB_FORUMNAME")).Text.Trim().ToString();
             int TXB_ROOTFORUMID = Convert.ToInt16(((TextBox)row.FindControl("TXB_ROOTFORUMID")).Text.Trim());
             int TXB_ISDISPLAY = Convert.ToInt16(((TextBox)row.FindControl("TXB_ISDISPLAY")).Text.Trim());
             string TXB_MASTER = ((TextBox)row.FindControl("TXB_MASTER")).Text.ToString();
             int TXB_ISLOCK = Convert.ToInt16(((TextBox)row.FindControl("TXB_ISLOCK")).Text.Trim());
             int LB_FORUMID=Convert.ToInt16(((Label)row.FindControl("Label6")).Text);
             ForumBLL.Forum_Update_Name(TXB_FORUMNAME, TXB_ISDISPLAY, TXB_ROOTFORUMID, TXB_MASTER, TXB_ISLOCK, LB_FORUMID);
         }
         catch (Exception ex)
         {
             Response.Write(ex);
         }
         GridView1.EditIndex = -1;
         BingGrid();
     }

GridView直接编辑,删除经典例子下载

时间: 2024-11-01 17:36:24

asp.net 编辑gridview的小例子_实用技巧的相关文章

asp.net中将js的返回值赋给asp.net控件的小例子_实用技巧

复制代码 代码如下:     <script language ="javascript" type ="text/javascript">    var second=0;    var minute=0;    var hour=0;    window .setInterval ("OnlineStayTimes();",1000);    function OnlineStayTimes()    {    second ++

ASP.NET Datagridview自动换行的小例子_实用技巧

复制代码 代码如下: protected void AxGridView1_RowDataBound(object sender, GridViewRowEventArgs e)    {        //设置所有列不允许换行        //AxGridView1.Attributes.Add("style", "word-break:keep-all;word-wrap:false");        //设置所有列自动换行        AxGridVie

asp.net中GridView控件遍历的小例子_实用技巧

复制代码 代码如下: int intCount = this.GridView1.Rows.Count; //总行数for (int i = 0; i < intCount; i++){  Label1.Text = ((HyperLink)GridView1.Rows[i].Cells[0].Controls[0]).Text.ToString().Trim(); } for (i = 0; i < GridViewID.Rows.Count; i++){   CheckBox chkVot

ASP.NET实现License Key输入功能的小例子_实用技巧

  这个演示,在输入时,是不需要与服务端交互,只有全部输入完毕之后,用户点铵钮才进行验证.因此在这里,写Javascript来实现即可. js: 复制代码 代码如下: <script type="text/javascript">        function JumpToNextTextBox(currentTxtBox, nextTextBoxID) {            if (currentTxtBox.value.length >= 5) {     

Asp.Net上传图片验证代码的小例子_实用技巧

一.客户端方式验证 复制代码 代码如下: <script language="javascript">img=new Image() ;function Check_FileTypeAndFileSize(){    //获得上传路径    var str=document.all.uploadFile.value;    //验证上传路径不为空    if(str=="")    {          alert("请先选择要上传的图片!&q

ASP.NET MVC处理文件上传的小例子_实用技巧

复制代码 代码如下: <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>Files uploaded to server</h2> <div id="dialog" title="Upload files"> <% using (Html.B

GridView中动态设置CommandField是否可用或可见的小例子_实用技巧

复制代码 代码如下:  protected void gvMaterial_RowDataBound(object sender, GridViewRowEventArgs e)        {            if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header)            {                e.Row.Cells[0].Vi

Asp.net中获取应用程序完整Url路径的小例子_实用技巧

复制代码 代码如下: /// <summary> /// Gets the absolute root /// </summary> public static Uri AbsoluteWebRoot {     get  www.jb51.net    {         var context = HttpContext.Current;         UriBuilder uri = new UriBuilder();         uri.Host = context.

ASP.Net获取客户端网卡MAC的小例子_实用技巧

复制代码 代码如下: using System.Text.RegularExpressions;using System.Diagnostics;public class test{        public test        {}        public static string GetCustomerMac(string IP) //para IP is the clients IP         {                string dirResults="&qu