| |

VerySource

 Forgot password?
 Register
Search
Author: vincentngacn

| M | Interview Today: I thought it was a simple question, but I couldn't do it. Very depressed, everyone analyzes

[Copy link]

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-4-22 22:30:01
| Show all posts
Do you think
When you click the details
Add a row to gridview
Then merge this line
Add a table?
if it is like this
row.Cells [0] .Text
Can it be
row.Cells [0] .Controls.Add (GridView);
Is it convenient to operate the data in detail?
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-4-24 08:45:02
| Show all posts
Front desk:

  <asp: GridView AutoGenerateColumns = "false" ID = "GridView1" runat = "server" OnRowDataBound = "GridView1_RowDataBound" OnRowCommand = "GridView1_RowCommand">
            <Columns>
                <asp: BoundField DataField = "Key" HeaderText = "Key" />
                 <asp: BoundField DataField = "Value" HeaderText = "Value" />
                 
                 <asp: ButtonField ButtonType = "Button" Text = "Detail" CommandName = "detail" />
               
              
            </ Columns>
        </ asp: GridView>
        
        <asp: Repeater ID = "rp1" runat = "server">
            <HeaderTemplate>
                <table border = "1">
                <tr>
                    <td> Category </ td>
                    <td> Time </ td>
                    <td> Amount </ td>
                </ tr>
            </ HeaderTemplate>
            <ItemTemplate>
                <TR>
                    <td> <% # Eval ("A")%> </ td>
                     <td> <% # Eval ("B")%> </ td>
                     <td> <% # Eval ("C")%> </ td>
                </ TR>
            </ ItemTemplate>
            <FooterTemplate>
                </ TABLE>
            </ FooterTemplate>
        </ asp: Repeater>
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-4-24 09:15:01
| Show all posts
Backstage:

 protected void Page_Load (object sender, EventArgs e)
    {

        
        System.Collections.Hashtable ht = new Hashtable ();
        ht.Add ("AA", true);
        ht.Add ("BB", false);
        ht.Add ("CC", "2");
        ht.Add ("DD", "3");
        ht.Add ("EE", "3");


        this.GridView1.DataSource = ht;
        this.GridView1.DataBind ();

        
       
        
    }


 protected void GridView1_RowCommand (object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "detail")
        {

           
            int iIndex = Convert.ToInt32 (e.CommandArgument);
  
            GridViewRow row = this.GridView1.Rows [iIndex];
            GridViewRow NewRow = new GridViewRow (iIndex + 1, iIndex, DataControlRowType.DataRow, DataControlRowState.Normal);
            NewRow.Cells.Add (new TableCell ());
            NewRow.Cells [0] .ColumnSpan = row.Cells.Count;
          


            DataTable dt = new DataTable ();
            dt.Columns.Add ("A", typeof (string));
            dt.Columns.Add ("B", typeof (string));
            dt.Columns.Add ("C", typeof (Int32));
            DataRow r1 = dt.NewRow ();
            r1 [0] = "Software Engineering";
            r1 [1] = "06-01-12";
            r1 [2] = 8000;
            dt.Rows.Add (r1);
            r1 = dt.NewRow ();
            r1 [0] = "Website Development";
            r1 [1] = "06-11-10";
            r1 [2] = 12000;
            dt.Rows.Add (r1);


            this.rp1.DataSource = dt.DefaultView;
            this.rp1.DataBind ();
            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-24 11:15:01
| Show all posts
This method is displayed and hidden through server events.

You can also generate html code. First hide it on the client. Click to show the hidden button.
Reply

Use magic Report

2

Threads

11

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-4-24 23:15:01
| Show all posts
Look first
Reply

Use magic Report

2

Threads

11

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-4-25 07:45:01
| Show all posts
It's perfect,
Thank you
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