This is a migrated thread and some comments may be shown as answers.

shopping cart session bind to Grid

1 Answer 36 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ching-Yen
Top achievements
Rank 1
Ching-Yen asked on 21 Mar 2009, 10:56 AM
Hi,

We are trying to do something like Telerik online purchase check out list where user could update the quality by using combobox and also delete product as they wish.

We only manage to bind the session to the Grid, but, we are not able to bind the delete command and also the edit to the Grid item. The RadGrid1_ItemDeleted will never been fired.

Please advice.

Dim objDT As System.Data.DataTable 
Dim objDR As System.Data.DataRow 
 
Protected Sub RadGrid1_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource 
objDT = Session("Cart"
RadGrid1.DataSource = objDT 
End Sub 
 
Protected Sub RadGrid1_ItemDeleted(ByVal source As ObjectByVal e As Telerik.Web.UI.GridDeletedEventArgs) Handles RadGrid1.ItemDeleted 
' Some code to delete 
End Sub 
 
Private Sub makeCart() 
If IsNothing(Session("Cart"))Then 
objDT = New System.Data.DataTable("Cart"
objDT.Columns.Add("ID"GetType(Integer)) 
objDT.Columns("ID").AutoIncrement = True 
objDT.Columns("ID").AutoIncrementSeed = 1 
objDT.Columns("ID").Unique = True 
objDT.Columns.Add("Quantity"GetType(Integer)) 
objDT.Columns.Add("ProductName"GetType(String)) 
objDT.Columns.Add("ProductID"GetType(Integer)) 
objDT.Columns.Add("Cost"GetType(Decimal)) 
Session("Cart") = objDT 
End Sub 

            <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" GridLines="None" ShowFooter="True" AllowPaging="True" AllowAutomaticDeletes="True" PageSize="20" AllowAutomaticUpdates="True" OnNeedDataSource="RadGrid1_NeedDataSource"
                <PagerStyle Mode="NextPrevAndNumeric" /> 
                <MasterTableView DataKeyNames="ID" HorizontalAlign="NotSet" AutoGenerateColumns="False"
                <Columns> 
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"
                        <ItemStyle CssClass="MyImageButton" /> 
                    </telerik:GridEditCommandColumn>                 
                    <telerik:GridBoundColumn Aggregate="Count" DataField="ID" HeaderText="Product ID" 
                        FooterText="Total products: " UniqueName="ID"
                    </telerik:GridBoundColumn>     
                    <telerik:GridBoundColumn DataField="ProductName" HeaderText="Product name" SortExpression="ProductName" 
                        UniqueName="ProductName"
                    </telerik:GridBoundColumn>      
                    <telerik:GridBoundColumn Aggregate="Sum" DataField="Cost" HeaderText="Unit price" 
                        FooterText="Total unit price: " UniqueName="Cost"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn Aggregate="Sum" DataField="Quantity" HeaderText="Qty" 
                        FooterText="All units in stock: " UniqueName="Quantity"
                    </telerik:GridBoundColumn>  
                    <telerik:GridCalculatedColumn HeaderText="Total Price" UniqueName="TotalPrice" DataType="System.Double" 
                        DataFields="Quantity, Cost" Expression="{0}*{1}" FooterText="Total Price: " 
                        Aggregate="Sum" />                                                              
                    <telerik:GridButtonColumn ConfirmText="Delete this product?" ButtonType="ImageButton" CommandName="Delete" Text="Delete" 
                        UniqueName="DeleteColumn"
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" /> 
                    </telerik:GridButtonColumn>                      
                </Columns> 
                </MasterTableView> 
                 
            </telerik:RadGrid> 



1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 23 Mar 2009, 07:53 AM
Hi Ching -Yen,

In the above provided code I did not find the event registered in the aspx side or code behind. Try setting the Event handler for the ItemDeleted event.

ASPX:

 
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" OnItemDeleted="RadGrid1_ItemDeleted" > 
             

VB:
 
 
     Protected Sub RadGrid1_ItemDeleted(ByVal source As ObjectByVal e As GridDeletedEventArgs) 
         
     End Sub 
 

Thanks
Shinu
Tags
Grid
Asked by
Ching-Yen
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or