Guys, I got a datagrid...
DataGrid1.BorderWidth = Unit.Pixel(2)
DataGrid1.CellPadding = 6
DataGrid1.GridLines = GridLines.Both
DataGrid1.BorderColor = Color.Black
DataGrid1.ShowHeader = True
DataGrid1.AutoGenerateColumns = False
DataGrid1.SelectedItemStyle.BackColor = Color.Beige
'add bound columns to the datagrid
Dim datagridcol As New BoundColumn
datagridcol.HeaderText = "Brand Name"
datagridcol.DataField = "strName"
DataGrid1.Columns.Add(datagridcol)
...and I've added a command...
Dim selectcol1 As New ButtonColumn
selectcol1.ButtonType = ButtonColumnType.PushButton
selectcol1.HeaderText = ""
selectcol1.Text = "Edit"
selectcol1.CommandName = "Edit Brand"
DataGrid1.Columns.Add(selectcol1)
...then I got an event handler to catch the "EditBrand" command which works as so...
Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand
Select Case e.CommandName
Case "Edit Brand"
Response.Write("EDIT PRESSED"
End Select
End Sub
...how the hell do I now get the name, id, whatever of the row I just clicked on?
- Jay
code@jay-hayman.co.uk
DataGrid1.BorderWidth = Unit.Pixel(2)
DataGrid1.CellPadding = 6
DataGrid1.GridLines = GridLines.Both
DataGrid1.BorderColor = Color.Black
DataGrid1.ShowHeader = True
DataGrid1.AutoGenerateColumns = False
DataGrid1.SelectedItemStyle.BackColor = Color.Beige
'add bound columns to the datagrid
Dim datagridcol As New BoundColumn
datagridcol.HeaderText = "Brand Name"
datagridcol.DataField = "strName"
DataGrid1.Columns.Add(datagridcol)
...and I've added a command...
Dim selectcol1 As New ButtonColumn
selectcol1.ButtonType = ButtonColumnType.PushButton
selectcol1.HeaderText = ""
selectcol1.Text = "Edit"
selectcol1.CommandName = "Edit Brand"
DataGrid1.Columns.Add(selectcol1)
...then I got an event handler to catch the "EditBrand" command which works as so...
Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand
Select Case e.CommandName
Case "Edit Brand"
Response.Write("EDIT PRESSED"
End Select
End Sub
...how the hell do I now get the name, id, whatever of the row I just clicked on?
- Jay
code@jay-hayman.co.uk