Jonel,
Here is the code. Thanks so much for your help
HTML
<form runat="server">
<asp
ataGrid runat="server" id="AdminGrid" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="3" Width="742px" Height="231px" DataKeyField="ProductID" AutoGenerateColumns="False" OnEditCommand="AdminGrid_EditCommand" OnCancelCommand="AdminGrid_CancelCommand" OnUpdateCommand="AdminGrid_UpdateCommand">
<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#669999"></SelectedItemStyle>
<ItemStyle ForeColor="#000066"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#006699"></HeaderStyle>
<FooterStyle ForeColor="#000066" BackColor="White"></FooterStyle>
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
<asp:BoundColumn DataField="ModelName" HeaderText="Product Name"></asp:BoundColumn>
<asp:BoundColumn DataField="ModelNumber" HeaderText="Product Number"></asp:BoundColumn>
<asp:BoundColumn DataField="ProductImage" HeaderText="Product Image"></asp:BoundColumn>
<asp:BoundColumn DataField="itemcount" HeaderText="Item Count">
<HeaderStyle Width="35px"></HeaderStyle>
</asp:BoundColumn>
<asp:HyperLinkColumn Text="Level Setup" DataNavigateUrlField="ProductID" NavigateUrl="AdminPrice.aspx?id={0}">
<HeaderStyle Width="35px"></HeaderStyle>
</asp:HyperLinkColumn>
<asp:BoundColumn DataField="description" HeaderText="Description">
<HeaderStyle Width="150px"></HeaderStyle>
</asp:BoundColumn>
</Columns>
<PagerStyle HorizontalAlign="Left" ForeColor="#000066" BackColor="White" Mode="NumericPages"></PagerStyle>
</asp
ataGrid></form>
'Code Behind
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
BindData()
End If
AddHandler AdminGrid.CancelCommand, AddressOf AdminGrid_CancelCommand
AddHandler AdminGrid.UpdateCommand, AddressOf AdminGrid_UpdateCommand
End Sub
Sub BindData()
Dim CategoryID As Integer = CInt(Request.Params("categoryid"))
' Obtain Product Details
Dim products As ProductsDB = New ProductsDB()
' Databind Gridcontrol with Shopping Cart Items
AdminGrid.DataSource = products.GetCompleteProductDetails(CategoryID)
AdminGrid.DataBind()
End Sub
Private Sub AdminGrid_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AdminGrid.SelectedIndexChanged
End Sub
Sub AdminGrid_EditCommand(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
AdminGrid.EditItemIndex = e.Item.ItemIndex
BindData()
End Sub
Sub AdminGrid_CancelCommand(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles AdminGrid.CancelCommand
System.Diagnostics.Debug.WriteLine("admingrid_cancel called")
AdminGrid.EditItemIndex = -1
BindData()
End Sub
Sub AdminGrid_UpdateCommand(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles AdminGrid.UpdateCommand
Dim product As ASPNET.StarterKit.Commerce.ProductsDB = New ASPNET.StarterKit.Commerce.ProductsDB()
'Iterate through all rows within datagrid
Dim i As Integer
For i = 0 To AdminGrid.Items.Count - 1
Dim ProductIdTxt As TextBox = CType(AdminGrid.Items(i).FindControl("productid"), TextBox)
Dim ModelNumberTxt As TextBox = CType(AdminGrid.Items(i).FindControl("ModelNumber"), TextBox)
Dim ModelNameTxt As TextBox = CType(AdminGrid.Items(i).FindControl("ModelName"), TextBox)
Dim ProductImageTxt As TextBox = CType(AdminGrid.Items(i).FindControl("ProductImage"), TextBox)
Dim DescriptionTxt As TextBox = CType(AdminGrid.Items(i).FindControl("Description"), TextBox)
Dim ItemCountTxt As TextBox = CType(AdminGrid.Items(i).FindControl("ItemCount"), TextBox)
Dim ProductId As Integer
Dim ModelNumber As String
Dim ModelName As String
Dim ProductImage As String
Dim Description As String
Dim ItemCount As Integer
product.UpdateDetails(ProductId, ModelNumber, ModelName, ProductImage, Description, ItemCount)
AdminGrid.EditItemIndex = -1
BindData()
Next
End Sub
Jonel Rienton said:
Brent,
are you hooking up the events manually or are you letting VS.Net IDE do
it for you? if the latter, check to make sure that the IDE is indeed
hooking up the events and the eventhandlers.
Jonel
[1] you can send me a snippet of your code offline if you'd like so i
can take a look at it.
Brent said:
Thanks Jonel,
I really appreciate your help. I do set a breakpoint and it never hits my
events. I also put the debug statement in and nothing.
I should tell you my AdminGrid_UpdateCommand will not fire either. I don't
know if that sheds any light on anything or not.
Thanks,
Brent
I am