InsertAt New Row in GridView (Adjust the Data Table to add Grid Rows to arbitrary positions)

patrick

Well-known member
Joined
Dec 5, 2021
Messages
238
Programming Experience
1-3
Hello.

Does GridView have this InsertAt ?

C#:
DataTable dt = new DataTable();

dt.Columns.Add("NO", typeof(int));
dt.Columns.Add("NAME", typeof(string));
dt.Columns.Add("HIREDATE", typeof(DateTime));
dt.Columns.Add("SALARY", typeof(int));

dt.Rows.Add(100, "Steven", "2003-06-17", 24000);
dt.Rows.Add(101, "Neena", "2005-09-21", 17000);

DataRow row = dt.NewRow();

row["NO"] = 104;
row["NAME"] = "Bruce";
row["HIREDATE"] = "2007-05-21";
row["SALARY"] = 6000;

dt.Rows.InsertAt(row, 1);

====================

I want to add GridView-B Rows to the row below 8 o'clock in GridView-A.

How should I program the algorithm for the GridView?

I'm not asking the InsertAt of the DataTable.

there are InsertAt of GridView?

attached file : gridview.png
 

Attachments

  • gridview.png
    gridview.png
    11.1 KB · Views: 23
It's always good to look at the documentation. Does the documentation show an InsertAt()?
 
It's always good to look at the documentation. Does the documentation show an InsertAt()?
There is no InsertAt in the document(GridView Class (System.Web.UI.WebControls)) you taught me.
I hope the grid's insertat function.
 
GridView.CreateRow() has a rowIndex parameter. This seems to suggest you can insert a row anywhere. I could be wrong though, and the documentation does not mention it. You may want to try it out.
 
The Telerik radGrid for WebForms seems to support drag/drop to it seems like it should support inserting between rows:

I am using Telerik:RadGrid in ASP.NET

In Telerik:RadGrid, Isn't there a function other than that of Telerik:RadGrid Drag/Drop?

telerik radgrid.png
 

According to this link:

Before we begin, there is one thing that needs to be cleared up. The GridView does not contain an option for inserting a row of data into the control itself or the underlying database table.

-=-=-=

If you are paying for Telerik, ask on their forum. They generally answer me with a helpful answer.

-=-=-=

How exactly are you planning on getting that data into a GridView without binding it to a datasource?

You can append a row to a Gridview with javascript. Maybe you can append the row to a GridView using javascript:


And then sort it with javascript:

 
Back
Top Bottom