Template Column with button in header

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

  1. #1

    Default Re: Template Column with button in header

    Hi,

    usually Button clicks inside DataGrid are managed by handling ItemCommand
    event of the grid. Button is given a CommandName that is checked in
    ItemCommand's event arguments (if there are multiple possibilities say
    multiple buttons with different purposes). If you need more information,
    please try describe your scenario more accurately.

    --
    Teemu Keiski
    MCP,Designer/Developer
    Mansoft tietotekniikka Oy
    [url]http://www.mansoft.fi[/url]

    ASP.NET Forums Moderator, [url]www.asp.net[/url]
    AspAlliance Columnist, [url]www.aspalliance.com[/url]

    Email:
    [email]joteke@aspalliance.com[/email]

    "IntraRELY" <IntraRELY@yahoo.com> kirjoitti viestissä
    news:%23u$Sn0QQDHA.2424@tk2msftngp13.phx.gbl...
    > Hello,
    >
    > I have a template column and in the header row I inserted a button. This
    > button creates a loop through the dataset and if it finds a check box it
    > opens a connection to the sql db and runs a delete stored procedure. When
    I
    > move this button outside the datagrid and just put it on the page it runs
    > correctly. Is there something that needs to be done in order to use a
    button
    > within a template column.
    >
    > TIA,
    >
    > Steve Wofford
    > [url]www.IntraRELY.com[/url]
    >
    >

    Teemu Keiski Guest

  2. Similar Questions and Discussions

    1. Header in a template column
      Hi, I have a checkbox in the header of a template column in a datagrid. How can I check during runtime that whether checkbox is checked or not?I...
    2. Changing ImageURL of Image Button which is added in template column of datagrid
      hello, I have a template column in my datagrid. To the header of template colum, i have added imagebutton. On click of the imagebutton , i...
    3. Image in header column (not replacing column header text)
      I have a sortable (asc/desc) datagrid and would like to add a small arrow icon (down/up) next to the column header text to improve the UI. Is this...
    4. Bound Column or Template Column (w dAdapater?) in DataGrid
      I am able to get the data using DataAdapter and the DataReader. I am more inclined to use DataAdapter because I want to update the data on the SQL...
    5. Button in column header
      I want to put a button in a column header. How do I handle the event when the button is clicked?
  3. #2

    Default Re: Template Column with button in header

    It is a datagrid filled by a dataset. There are 6 columns and one template
    column that is filled with checkboxes. In the header row of the checkbox
    column there is a delete button which is used to delete all checked rows in
    the datagrid. Here is the working code for when the botton is clicked.
    Remember that when the button is used outside the datagrid this code works
    correctly. However when the button is placed within the datagrid nothing
    happens.

    Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles btnDelete.Click
    'Dim rowCount As Integer = 0
    'Dim gridSelections As StringBuilder = New StringBuilder
    Dim userIdItem As DataGridItem
    'Open User Manager page's connection to SQL Database
    SqlUserManager.Open()
    cmdUsersDelete.CommandType = System.Data.CommandType.StoredProcedure
    cmdUsersDelete.CommandText = "sp_usersdelete"
    cmdUsersDelete.Connection = SqlUserManager
    'Run through each row in the DataSet
    For Each userIdItem In dgUserManager.Items
    'Check to see if row is check
    Dim myCheckbox As CheckBox = CType(userIdItem.Cells(6).Controls(1),
    CheckBox)
    'If checkbox is checked
    If myCheckbox.Checked = True Then
    'Set variable for userId" for delete
    Dim selectedUserId
    selectedUserId = dgUserManager.DataKeys(userIdItem.ItemIndex)
    'Add variable as parameter to sp_usersdelete stored procedure
    With cmdUsersDelete
    ..Parameters("@UserId").Value = selectedUserId
    End With
    Dim eNonQuery As Integer
    Try
    'Execute stored procedure
    eNonQuery = cmdUsersDelete.ExecuteNonQuery
    'Catch stored procedure's error message
    Catch ex As System.Data.SqlClient.SqlException
    lblMessage.Text = ex.Message
    Finally
    End Try
    End If
    Next
    'Close database resources
    SqlUserManager.Close()
    daUserManager.Fill(DsUserManager)
    dgUserManager.DataBind()
    End Sub

    Thanks for you input,

    Steve Wofford
    [url]www.IntraRELY.com[/url]




    "Teemu Keiski" <joteke@aspalliance.com> wrote in message
    news:eEOuowSQDHA.3880@tk2msftngp13.phx.gbl...
    > Hi,
    >
    > usually Button clicks inside DataGrid are managed by handling ItemCommand
    > event of the grid. Button is given a CommandName that is checked in
    > ItemCommand's event arguments (if there are multiple possibilities say
    > multiple buttons with different purposes). If you need more information,
    > please try describe your scenario more accurately.
    >
    > --
    > Teemu Keiski
    > MCP,Designer/Developer
    > Mansoft tietotekniikka Oy
    > [url]http://www.mansoft.fi[/url]
    >
    > ASP.NET Forums Moderator, [url]www.asp.net[/url]
    > AspAlliance Columnist, [url]www.aspalliance.com[/url]
    >
    > Email:
    > [email]joteke@aspalliance.com[/email]
    >
    > "IntraRELY" <IntraRELY@yahoo.com> kirjoitti viestissä
    > news:%23u$Sn0QQDHA.2424@tk2msftngp13.phx.gbl...
    > > Hello,
    > >
    > > I have a template column and in the header row I inserted a button. This
    > > button creates a loop through the dataset and if it finds a check box it
    > > opens a connection to the sql db and runs a delete stored procedure.
    When
    > I
    > > move this button outside the datagrid and just put it on the page it
    runs
    > > correctly. Is there something that needs to be done in order to use a
    > button
    > > within a template column.
    > >
    > > TIA,
    > >
    > > Steve Wofford
    > > [url]www.IntraRELY.com[/url]
    > >
    > >
    >
    >

    IntraRELY Guest

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