| |

VerySource

 Forgot password?
 Register
Search
View: 14|Reply: 10

Urgent !!! There is a layout column in DATAGRID, to add a row

[Copy link]

2

Threads

7

Posts

7

Credits

Newbie

Rank: 1

Credits
7

 China

Post time: 2020-3-8 22:00:02
| Show all posts |Read mode
In DATAGRID, there are 3 layout columns containing LINKBUTTON, TEXTBOX, and DROPDOWNLIST.
Now I hope that clicking on LINKBUTTON will add another line at the end of DATAGRID (also contains LINKBUTTON, TEXTBOX and DROPDOWNLIST.)
I want to use
DataTable dt = new DataTable ();
TextBox tmp = new TextBox ();
dt.Columns.Add (new DataColumn ("textbox", tmp));
DataRow dr = dt.NewRow ();
To implement, but the tmp is wrong, I don't know if the DataColumn can do this?
Or is there any other method?
Thank you
Reply

Use magic Report

0

Threads

301

Posts

108

Credits

Newbie

Rank: 1

Credits
108

 China

Post time: 2020-5-29 18:00:01
| Show all posts
dt is datatable

dt.Columns.Add is to add a field.
How to add textbox to the data table?
Reply

Use magic Report

0

Threads

301

Posts

108

Credits

Newbie

Rank: 1

Credits
108

 China

Post time: 2020-5-29 18:45:01
| Show all posts
Add a blank line of data directly to the data source.
Reply

Use magic Report

0

Threads

301

Posts

108

Credits

Newbie

Rank: 1

Credits
108

 China

Post time: 2020-5-29 20:30:02
| Show all posts
DataTable dt = // Query data
DataRow newDR = dt.NewRow ();

 

dt.Rows.Add (newDR);
dt.Rows.InsertAt (newDR, dt.Rows.Count);
Reply

Use magic Report

0

Threads

12

Posts

13

Credits

Newbie

Rank: 1

Credits
13

 China

Post time: 2020-5-30 10:45:01
| Show all posts
Add another line at the end of DATAGRID
-----------------------------
Make datarow dr = datatable.newrow () of the data source; then assign values ​​to each column of dr
Your code puts the textbox in the datacolumn, then the controls in the template column on the page cannot bind the value (textbox type), just put the value in the datacolumn and bind it to the datagrid
Reply

Use magic Report

0

Threads

1

Posts

2

Credits

Newbie

Rank: 1

Credits
2

 China

Post time: 2020-5-30 11:00:01
| Show all posts
It will be too late, hey ~.
Learn fromshenmue024.
Reply

Use magic Report

2

Threads

7

Posts

7

Credits

Newbie

Rank: 1

Credits
7

 China

 Author| Post time: 2020-5-30 12:30:01
| Show all posts
DataTable dt = new DataTable ();
DataRow dr = dt.NewRow ();
this.DataGrid1.DataSource = dt;
this.DataGrid1.DataBind ();
error: DataGrid with ID "DataGrid1" failed to automatically generate any columns from the selected data source.
Reply

Use magic Report

0

Threads

301

Posts

108

Credits

Newbie

Rank: 1

Credits
108

 China

Post time: 2020-5-30 18:15:01
| Show all posts
DataTable dt = new DataTable ();

// This dt should be the table you get by querying the database.

If you new one, you should add columns
Reply

Use magic Report

2

Threads

7

Posts

7

Credits

Newbie

Rank: 1

Credits
7

 China

 Author| Post time: 2020-6-1 14:00:01
| Show all posts
Reply

Use magic Report

2

Threads

7

Posts

7

Credits

Newbie

Rank: 1

Credits
7

 China

 Author| Post time: 2020-6-1 14:15:01
| Show all posts
You don't need to go to the database to query, you just need to have a blank line that contains LINKBUTTON, TEXTBOX, and DROPDOWNLIST DATAGRID. Then click LINKBUTTON. A new line will be generated.
With DataTable dt = new DataTable (); columns should be added
Just don't know how to add columns
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2020|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list