Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ASCX.

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CartControl.ascx.cs" Inherits="CartControl" %>
<style type="text/css">
    .style1
    {
        text-align: center;
    }
</style>
<div class="style1">
    style="color: #FFFFFF; font-size: xx-large"><br />
Your Shopping Cart
</div>
<br />
<asp:GridView ID="grdCart" runat="server" AutoGenerateColumns="False" 
    DataKeyNames="ProductID" OnRowCancelingEdit="grdCart_RowCancelingEdit" 
    OnRowDeleting="grdCart_RowDeleting" OnRowEditing="grdCart_RowEditing" 
    OnRowUpdating="grdCart_RowUpdating" BackColor="#CCCCCC" BorderColor="#999999" 
    BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" 
    ForeColor="Black" style="margin-left: 158px" 
    >
    <columns>
       
    <asp:TemplateField>
            <itemtemplate>
                <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("filename") %>' />
            </itemtemplate>
        
        <asp:BoundField DataField="ProductID" HeaderText="ID" ReadOnly="True" />
        <asp:BoundField DataField="ProductName" HeaderText="Product" ReadOnly="True" />
        <asp:BoundField DataField="Quantity" HeaderText="Quantity" />
        <asp:BoundField DataField="Price" DataFormatString="{0:c}" HeaderText="Price" ReadOnly="True" />
        <asp:BoundField DataField="SubTotal" DataFormatString="{0:c}" HeaderText="Total"
            ReadOnly="True" />
        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True"/>
    </columns>
    <emptydatatemplate>
        Your Shopping Cart is empty, add items
        <a href="Products.aspx" style="font-size: 11px; color: black">Add Products</a>
    </emptydatatemplate>
    <footerstyle backcolor="#CCCCCC" />
    <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
    <pagerstyle backcolor="#CCCCCC" forecolor="Black" horizontalalign="Left" />
    <rowstyle backcolor="White" />
    <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
    <sortedascendingcellstyle backcolor="#F1F1F1" />
    <sortedascendingheaderstyle backcolor="#808080" />
    <sorteddescendingcellstyle backcolor="#CAC9C9" />
    <sorteddescendingheaderstyle backcolor="#383838" />

<asp:Label ID="TotalLabel" runat="server" 
    style="margin-left: 247px; font-weight: 700; color: #FFFFFF;"><br />
    <asp:ImageButton ID="btnCashOut" runat="server" ImageUrl="~/Image/cashoutd.png" 
    style="margin-left: 247px; margin-top: 0px" onclick="btnCashOut_Click"/>
Posted
Updated 31-Jan-14 5:38am
v2
Comments
JoCodes 31-Jan-14 11:44am    
You mean to say you are passing complete GridView with value to another page and displaying? Or a particular Selected Row value on ImageButton Click?
dlsudStudent 1-Feb-14 3:58am    
Complete gridview sir. All the value in gridview. Im creating Shopping Cart and I want to pass all the items that add to gridview and pass it to Cashout.aspx.
JoCodes 1-Feb-14 5:21am    
Try this http://rajudasa.blogspot.in/2011/08/aspnet-passing-gridview-control-from.html
dlsudStudent 1-Feb-14 7:40am    
Thanks bro. :)
dlsudStudent 1-Feb-14 7:43am    
if (!IsPostBack)
{

FillGrid(); //Your logic to fill gridview
}

What "//Your logic to fill gridview" means? I get a error in here "FillGrid(); ".

Your best bet is to store the underlying data in session or cache and then reference that again from the other page. Dont try and store data in cookie etc.
 
Share this answer
 
In case passing GridView to another page refer

http://rajudasa.blogspot.in/2011/08/aspnet-passing-gridview-control-from.html[^]

Here other approach can be using Session but it will be expensive.

Passing Row from one page to another, refer

http://aspsnippets.com/Articles/ASPNet-Pass-or-Send-GridView-Row-Values-to-other-Page-with-HyperLink.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900