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.
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 Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource |
objDT = Session("Cart") |
RadGrid1.DataSource = objDT |
End Sub |
Protected Sub RadGrid1_ItemDeleted(ByVal source As Object, ByVal 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> |