adding button to header, footer or Pager of dataGrid

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default adding button to header, footer or Pager of dataGrid


    hi
    i want to know whether is it possible to add button (say DELETE button)
    in the header,footer or Pager of a dataGrid?
    If yes,how do i achieve the same?
    thnkx
    cheers

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    rosh Guest

  2. Similar Questions and Discussions

    1. Customizing pager/header/footer
      I need to put web controls inside pager, header or footer parts of the datagrid. Any ideas?
    2. Adding ImageButton to a datagrid header
      Ok, o I have a datagrid with sorting and paging. I would like to add a small ImageButton right under the header text that I currently use for...
    3. Adding ImageButton To DataGrid Header
      Hello This is probable a simple one for all you experts out there. I was wondering what the most efficient way of dynamically assigning a URL...
    4. Nested Datagrid Inner Grid adding button column
      I'm creating a hierarchical, editable ASP.NET datagrid with drilldown using two SQL tables. The "child" rows sit inside a cell of its "parent". ...
    5. Adding textboxes for filtering in DataGrid header
      Hi All, - Visual Studio 2002 - VB.NET > ASP.NET I created a DataGrid on a webform. This datagrid has sorting enabled. I want to create in the...
  3. #2

    Default Re: adding button to header, footer or Pager of dataGrid

    Header and footer are easy enough. Which ever column you want the button in,
    simply make it a template column, and then edit the template by
    right-clicking the grid and going to "Edit Template..."

    You can also do it through code, which would be the only way if you want to
    edit the pager. You can handle the OnItemCreated event for the grid, then do
    a Select Case e.Item.ItemType, and look for the type you want to edit. Then
    go ahead and add your controls as you wish.
    ** The only caveat about doing it in code is that it CAN potentially become
    very tricky to create and recreate this controls properly on postbacks and
    rebinds, because of issues with needing to create the pages
    viewstate/control hierarchy in excatly the same fashion it was originally
    created.

    I hope this helps you some.

    "rosh" <urgent@devdex.com> wrote in message
    news:ON2VuEErEHA.2856@TK2MSFTNGP10.phx.gbl...
    >
    > hi
    > i want to know whether is it possible to add button (say DELETE button)
    > in the header,footer or Pager of a dataGrid?
    > If yes,how do i achieve the same?
    > thnkx
    > cheers
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    A Traveler Guest

  4. #3

    Default Re: adding button to header, footer or Pager of dataGrid


    thnkx a lot for ru quick reply :)
    yeh tht worked :)
    now i will try the same on PAGER of the dataGrid
    now one more question arrises as to whether can i do the same by adding
    image buttons?
    I have a header fielt say "SortIt" and i want that column to be sorted
    both ways(ascd'ng and descending)and also i want to append the image to
    the header text "SortIt"[image]
    All i want is when i click on this header the sorting must take place
    and the image must change according to ascenging n descending sort...
    i tried this by adding a Header Image through ProgramBuilder but then if
    i add the image from there i am not able to see my header text :( wht do
    i do?
    can u suggest some idea for the same
    have a nice time
    cheers

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    rosh Guest

  5. #4

    Default Re: adding button to header, footer or Pager of dataGrid

    Private Sub gvResults_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvResults.RowCreated
    ' After Row is created, see what type of row it was
    Select Case e.Row.RowType
    ' Find the Pager Row
    Case DataControlRowType.Pager
    ' Build LinkButton and create handler
    Dim LnkBtnExport As New LinkButton
    LnkBtnExport.ID = "LnkBtnExport"
    LnkBtnExport.Text = "Export To Excel"
    AddHandler LnkBtnExport.Click, AddressOf LnkBtnExportClicked

    ' Create a New Table Cell
    Dim tc As New TableCell

    ' Add Table Cell to the inside of the Pager Table
    ' e.row.cells(0).Controls(0) is the table
    ' e.row.cells(0).controls(0).controls(0) is the TR
    ' e.row.cells(0).controls(0).controls(0).Controls is the TD collection
    e.Row.Cells(0).Controls(0).Controls(0).Controls.Ad d(tc)

    ' add the link button to the new table cell
    tc.Controls.Add(LnkBtnExport)
    End Select
    End Sub

    Private Sub LnkBtnExportClicked(ByVal sender As Object, ByVal e As EventArgs)
    ' BUILD BUTTON FUNCTION HERE
    End Sub
    Travis Walker is offline Junior Member
    Join Date
    Apr 2011
    Posts
    1

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139