| |

VerySource

 Forgot password?
 Register
Search
View: 1772|Reply: 22

Please explain some code just now, thank you

[Copy link]

2

Threads

11

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-2-19 12:30:01
| Show all posts |Read mode
int iIndex = Convert.ToInt32 (e.CommandArgument);
What value does e.commandargument get in the foreground? <Asp: ButtonField ButtonType = "Button" Text = "detail" CommandName = "detail" /> does not have a commandargument value.
I click here. Its value is the current row index. Does this mean?

            GridViewRow row = this.GridView1.Rows [iIndex];
            GridViewRow NewRow = new GridViewRow (iIndex + 1, iIndex, DataControlRowType.DataRow, DataControlRowState.Normal);
// In this line (iIndex + 1, iIndex, DataControlRowType.DataRow, DataControlRowState.Normal);
DataControlRowType.DataRow, DataControlRowState.Normal refers to the type and state of the new behavior. What I don't understand is the previous iIndex + 1, iIndex,

            NewRow.Cells.Add (new TableCell ());
// Why should NewRow.Cells.Add (new TableCell ());
            NewRow.Cells [0] .ColumnSpan = row.Cells.Count;

...

            this.GridView1.Controls [0] .Controls.AddAt (iIndex + 2, NewRow);

            NewRow.Cells [0] .Controls.Add (this.rp1);
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-4-26 09:15:01
| Show all posts
commandargument is actually the current line number.
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-4-26 11:00:01
| Show all posts
iIndex + 1 refers to the row after the current row.

The second iIndex refers to the location of the corresponding data source. In fact, it does not matter, because he does not bind the data
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-4-26 11:30:01
| Show all posts
Of course, if you want to query it from the table, you can use it.
Reply

Use magic Report

2

Threads

11

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-4-26 11:45:01
| Show all posts
That iIndex + 1, iIndex ,? ? ?
 NewRow.Cells.Add (new TableCell ()); whether to add columns
(Whether the row is added when the row is added, and the content will be displayed only if the column is added)
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-4-26 12:00:01
| Show all posts
// Why do you need NewRow.Cells.Add (new TableCell ()); here?
There are no cells in this row.
Must be added manually
Reply

Use magic Report

2

Threads

11

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-4-26 13:15:01
| Show all posts
Because the description of iIndex + 1, iIndex, is not clear what he said is not clear
So I do n’t know what these two mean
I can't make mistakes if I change them to something else: 0,0,
Reply

Use magic Report

2

Threads

11

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-4-26 14:30:01
| Show all posts
// Why do you need NewRow.Cells.Add (new TableCell ()); here?
There are no cells in this row.
Must be added manually
-------------------------
Will the number of single grids be the number of single grids in the previous row as soon as he is added?
There should be only one
And he has not
this.GridView1.Controls [0] .Controls.AddAt (iIndex + 2, NewRow);
how can
NewRow.Cells [0] .ColumnSpan = row.Cells.Count;
At this time, the number of NewRow.cells should be 1
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-4-26 14:45:01
| Show all posts
I can't make mistakes if I change them to something else: 0,0,
===========
Because this row is added manually, this rowIndex and DataItemIndex are meaningless.
However, this parameter must be specified when new.
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-4-26 15:15:01
| Show all posts
NewRow.Cells.Add (new TableCell ());

This is to add only one cell, which has nothing to do with the previous row, because this row is not derived from the bound data.

It is new.




NewRow.Cells [0] .ColumnSpan = row.Cells.Count;
At this time, the number of NewRow.cells should be 1
=========
Yes, but after the = sign is row row is the original row, the existing
 GridViewRow row = this.GridView1.Rows [iIndex];
Reply

Use magic Report

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

Points Rules

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

Quick Reply To Top Return to the list