Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a Gridview with 3 Template fields in which 2 are text boxes and one will be a button field.So while a button is clicked an empty row should be displayed with no values in both the text box fields and the button field.


Could you please suggest how to achieve this...


Thanks & Regards,
Mathi
Posted

Check the following links:
Adding rows into Gridview in C# Asp.net [^]
Dynamically adding and deleting rows from ASP.NET GridView[^]
Add Row to ASP.NET GridView?[^]

So you basically set the value to String.Empty or "".

Good luck,
OI
 
Share this answer
 
Comments
Mathi2code 10-May-13 0:20am    
is there a way that I can do the same in Javascript...
Mathi2code 10-May-13 2:41am    
Thanks a lot
Orcun Iyigun 10-May-13 4:52am    
You are welcome.
C#
DataTable dtMytable = new DataTable();
dtMytable.Columns.Add("Title");
dtMytable.Columns.Add("Description");
dtMytable.Columns.Add("Weightage");
DataRow dr = dtMytable.NewRow();
dtMytable.Rows.Add(dr);

MyGrid.Visible = true;
MyGrid.DataSource = dtMytable;
MyGrid.DataBind();
 
Share this answer
 
Hi The below code is working


C#
DataTable dtMytable = new DataTable();
dtMytable.Columns.Add("Title");
dtMytable.Columns.Add("Description");
dtMytable.Columns.Add("Weightage");
DataRow dr = dtMytable.NewRow();
dtMytable.Rows.Add(dr);

MyGrid.Visible = true;
MyGrid.DataSource = dtMytable;
MyGrid.DataBind();
 
Share this answer
 

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