Click here to Skip to main content
15,912,977 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Whats wrong in following code for inserting row with value in gridview

public void GRID(string abcd, string mat, string ilength, string llength,
C#
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);
                
            
        }
Posted
Updated 5-Jan-15 17:58pm
v2
Comments
Suvendu Shekhar Giri 6-Jan-15 0:03am    
Looks fine. Try putting a breakpoint and debug. Check for any exception.
Member 11270220 6-Jan-15 0:12am    
no exception but cant insert row new value in gridview new row

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900