结合C#,ASP.net后加入gridview的新行 [英] add new row in gridview after binding C#, ASP.net

查看:185
本文介绍了结合C#,ASP.net后加入gridview的新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要点击下面的链接按钮时所看到的图片后绑定到新的空白行添加到GridView。 GridView控件内的文本框应保持相同,如果在它进入的任何数据。只想补充一行。请帮帮我。先谢谢了。

I want to add a new blank row to the gridview after binding as seen in the picture when clicking the link button below. The textboxes inside the gridview should remain the same if there is any data entered in it. just want to add one row. please help me. Thanks in advance.

推荐答案

您可以尝试以下code

you can try the following code

protected void Button1_Click(object sender, EventArgs e)
   {
       DataTable dt = new DataTable();

       if (dt.Columns.Count == 0)
       {
           dt.Columns.Add("PayScale", typeof(string));
           dt.Columns.Add("IncrementAmt", typeof(string));
           dt.Columns.Add("Period", typeof(string));
       }

       DataRow NewRow = dt.NewRow();
       NewRow[0] = TextBox1.Text;
       NewRow[1] = TextBox2.Text;
       dt.Rows.Add(NewRow); 
       GridView1.DataSource = dt;
       GridViewl.DataBind();
   }

在这里PayScale的,incrementamt和周期的数据库字段名。

here payscale,incrementamt and period are database field name.

这篇关于结合C#,ASP.net后加入gridview的新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆