如何在gridview中添加带有值的行 [英] how to add row with value in gridview

查看:73
本文介绍了如何在gridview中添加带有值的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码在gridview中插入带有值的行有什么错误



public void GRID(string abcd,string mat,string ilength,string llength,

Whats wrong in following code for inserting row with value in gridview

public void GRID(string abcd, string mat, string ilength, string llength,

string mount, string style, string tip, string root, string thread)
        {
           
                string aaaa = abcd;
                string mattype = mat;
                string ilength = ilength;
                string lglength = llength;
                string mountc = mount, ;
                string style = style;
                string tipd = tip;
                string rootd = root;
                string thread = thread;              
                DataTable dt = new DataTable();
                bool flag = false;
                if (!flag)
                {
                    dt.Columns.Add("Model", typeof(string));
                    dt.Columns.Add("Code", typeof(string));
                    dt.Columns.Add(" Type", typeof(string));
                    dt.Columns.Add("MatType", typeof(string));
                    dt.Columns.Add("ILength", typeof(string));
                    dt.Columns.Add("LLength", typeof(string));
                    dt.Columns.Add("Specification", typeof(string));
                    dt.Columns.Add(" Style", typeof(string));
                    dt.Columns.Add("Tip ", typeof(string));
                    dt.Columns.Add("Root ", typeof(string));
                    dt.Columns.Add("Instru", typeof(string));

                    DataRow row = dt.NewRow();
                    row["Model"] = TxtCCode.Text;
                    row["Code"] = TxtMoCode.Text;
                    row["Type"] = aaaa;
                    row["MatType"] = mattype;
                    row["ILength"] = ilength;
                    row["LLength"] = lglength;
                    row["Specification"] = mountc;
                    row["Style"] = style;
                    row["Tip"] = tipd;
                    row["Root"] = rootd;
                    row["Instr"] = thread;
                    dt.Rows.Add(row);
                    Grd.DataSource = dt;
                    Grd.DataBind();
                }
                              
        }


        public void get()
        {                                 
                GRID(tstyle, mattype, ilength, laglength, mountf, sttyle, tip, root, insthread);
                
            
        }

推荐答案

http://www.aspsnippets.com/Articles/Add-new-Row-to-GridView-on -Button-Click-in-ASPNet.aspx [ ^ ]


http://asphelps.com/GridView/How-to-insert-new-rows-in-GridView-in-Asp.Net .aspx [ ^ ]


这篇关于如何在gridview中添加带有值的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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