user1292656
user1292656

Reputation: 2560

Insert custom Button inside Gridview pager

I am trying to insert a control inside Gridview pager. The Control appears successfuly but it assign it under the previous control as you can see in the picture.

enter image description here

I am adding with the following code.

if (e.Row.RowType == DataControlRowType.Pager)
{
    e.Row.Cells[0].Controls.Add(ImageButton1);
}

What i want is to assign the Save Answers button next to Previous button and not below. Any help pls ?

Upvotes: 2

Views: 1793

Answers (2)

user1292656
user1292656

Reputation: 2560

if (e.Row.RowType == DataControlRowType.Pager)
{
    Table pagerTable = (e.Row.Cells[0].Controls[0] as Table);
    TableRow row = new TableRow();
    row = pagerTable.Rows[0];
    TableCell cell1 = new TableCell();
    cell1.Controls.Add(ImageButton1);

    row.Cells.AddAt(1,cell1);
}

Upvotes: 2

GeorgesD
GeorgesD

Reputation: 1082

Maybe you can add a pager style in your gridview:

<PagerStyle Width="100%" />

Why don't you create a pagertemplate with your button inside ? It will be easier for you to define the positions of each button.

 <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSource" 
        autogeneratecolumns="false"
        emptydatatext="No data available." 
        allowpaging="true" 
        runat="server">
...
        <pagerstyle Width="100%"/>

      </asp:gridview>

Upvotes: 0

Related Questions