Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
cjb@goldmancg.com #1
Datagrid Cancle/update button calles delete command?
Hi,
I'm trying to extend the DataGrid class, and I think I am getting my
wires crossed.
In the constructor I add my colums:
Public Sub New()
connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB
Services=-4; Data Source=" + HttpContext.Current.Server.MapPath(".\") +
"picPost.mdb;"
HeaderStyle.BackColor =
System.Drawing.Color.FromArgb(CType("&H999966", Integer))
ItemStyle.BackColor =
System.Drawing.Color.FromArgb(CType("&HAAC1F8", Integer))
AlternatingItemStyle.BackColor =
System.Drawing.Color.FromArgb(CType("&HFFFF99", Integer))
EditItemStyle.BackColor =
System.Drawing.Color.FromArgb(CType("&HEEEEEE", Integer))
itemCreatedIteration = 0
Dim editColumn As System.Web.UI.WebControls.EditCommandColumn =
New System.Web.UI.WebControls.EditCommandColumn()
Dim deleteColumn As System.Web.UI.WebControls.ButtonColumn =
New System.Web.UI.WebControls.ButtonColumn()
Dim eventColumn As System.Web.UI.WebControls.BoundColumn = New
BoundColumn()
Dim indexColumn As System.Web.UI.WebControls.BoundColumn = New
BoundColumn()
''Setupt the delteColumn
deleteColumn.ButtonType = ButtonColumnType.PushButton
deleteColumn.CommandName = "Delete"
deleteColumn.Text = "Remove"
''Setup the EditCommand Column
editColumn.EditText = "Edit"
editColumn.ButtonType = ButtonColumnType.PushButton
editColumn.CancelText = "Cancle"
editColumn.UpdateText = "Update"
''setup the bound columns
indexColumn.DataField = "pk_event"
indexColumn.Visible = False
eventColumn.DataField = "EventName"
eventColumn.HeaderText = "Bound Events"
''Add the new columns
Columns.Add(indexColumn)
Columns.Add(eventColumn)
Columns.AddAt(Columns.Count, editColumn)
Columns.AddAt(Columns.Count, deleteColumn)
AutoGenerateColumns = False
ShowFooter = True
populateGrid()
''OnEditCommand="DG_Events_Edit"
OnCancelCommand="DG_Events_Cancel" OnDeleteCommand="DG_Events_Delete"
End Sub
Then I extend the built in event handlers
Protected Overrides Sub OnDeleteCommand(ByVal e As
DataGridCommandEventArgs)
MyBase.OnDeleteCommand(e)
HttpContext.Current.Response.Write("got Delete <br />")
Dim indexToDelete As Integer
indexToDelete = CType(e.Item.Cells(0).Text, Integer)
DeleteEvent(indexToDelete)
populateGrid()
End Sub
Protected Overrides Sub OnEditCommand(ByVal E As
DataGridCommandEventArgs)
MyBase.OnEditCommand(E)
Me.EditItemIndex = E.Item.ItemIndex
HttpContext.Current.Response.Write("got the editCommand")
DataBind()
End Sub
Protected Overrides Sub OnCancelCommand(ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs )
MyBase.OnCancelCommand(e)
Me.EditItemIndex = -1
populateGrid()
End Sub
My problem is, Edit gets called just fine, delete gets called just
fine, but when I hit cancel, ondeletecommand gets called, and when I
hit update ondeletecommand gets called.
I also added a button add, and the events work fine for that.
Can anyone shed any light on my mistake?
Thanks,
CJB
cjb@goldmancg.com Guest
-
Datagrid item renderer delete button
I have a datagrid with an item renderer. In the item renderer is a delete button img. Onclick it will remove the item from the datagrid with the... -
Datagrid Update Command
Any help PLEASE! I have a datagrid on a aspx page. The editcommand and cancelcommand work as explected however my updatecommand is not. My... -
delete button problems in datagrid
i have a datagrid with a delete button which for some reason quit working, i'm thinking its a problem with the database but here is the code:... -
ASP/VBS Using Command to Insert/Update/Delete
Hi, I would just like to know when/why etc would you command and if there any penalties in using the command. Thanks, Sanjay -
Trigger Datagrid Edit From Command Button
Hey all, I was wanting to know if this was possible. I have a Datagrid with inline editing capabilites and all that jazz, it all works. What I... -
cjb@goldmancg.com #2
Re: Datagrid Cancle/update button calles delete command?
My Problem was here:
Protected Overrides Sub OnEditCommand(ByVal E As
DataGridCommandEventArgs)
MyBase.OnEditCommand(E)
Me.EditItemIndex = E.Item.ItemIndex
HttpContext.Current.Response.Write("got the editCommand")
DataBind()
End Sub
My DataBind() should have been populateGrid, which is were I populate
the dataset.
cjb@goldmancg.com Guest



Reply With Quote

