如何获取gridview的所有值并使用图像按钮将其传递到另一个页面? [英] How can I get all the value of gridview and pass it to another page using image button?

查看:79
本文介绍了如何获取gridview的所有值并使用图像按钮将其传递到另一个页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ASCX。



<%@ Control Language =C#AutoEventWireup =trueCodeFile =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 />
您的购物车
< / div>
< br />
< asp:GridView ID =grdCartrunat =serverAutoGenerateColumns =False
DataKeyNames =ProductIDOnRowCancelingEdit =grdCart_RowCancelingEdit
OnRowDeleting =grdCart_RowDeletingOnRowEditing = grdCart_RowEditing
OnRowUpdating =grdCart_RowUpdatingBackColor =#CCCCCCBorderColor =#999999
BorderStyle =SolidBorderWidth =3pxCellPadding =4CellSpacing =2
ForeColor =黑色样式=margin-left:158px
>
< columns>

< asp:TemplateField>
< itemtemplate>
< asp:图片ID =Image1runat =serverImageUrl ='<%#Eval(filename)%>'/>
< / itemtemplate>

< asp:BoundField DataField =ProductIDHeaderText =IDReadOnly =True/>
< asp:BoundField DataField =ProductNameHeaderText =ProductReadOnly =True/>
< asp:BoundField DataField =QuantityHeaderText =Quantity/>
< asp:BoundField DataField =PriceDataFormatString ={0:c}HeaderText =PriceReadOnly =True/>
< asp:BoundField DataField =SubTotalDataFormatString ={0:c}HeaderText =Total
ReadOnly =True/>
< asp:CommandField ShowDeleteButton =TrueShowEditButton =True/>
< / columns>
< emptydatatemplate>
您的购物车为空,添加商品
< a href =Products.aspxstyle =font-size:11px; color:black>添加商品< / a>
< / emptydatatemplate>
< footerstyle backcolor =#CCCCCC/>
< HeaderStyle BackColor =BlackFont-Bold =TrueForeColor =White/>
< pagerstyle backcolor =#CCCCCCforecolor =Blackhorizo​​ntalalign =Left/>
< rowstyle backcolor =White/>
< SelectedRowStyle BackColor =#000099Font-Bold =TrueForeColor =White/>
< sortedascendingcellstyle backcolor =#F1F1F1/>
< sortedascendingheaderstyle backcolor =#808080/>
< sorteddescendingcellstyle backcolor =#CAC9C9/>
< sorteddescendingheaderstyle backcolor =#383838/>

< asp:Label ID =TotalLabelrunat =server
style =margin-left:247px; font-weight:700; color:#FFFFFF;> < br />
< asp:ImageButton ID =btnCashOutrunat =serverImageUrl =〜/ Image / cashoutd.png
style =margin-left:247px; margin-top:0pxonclick =btnCashOut_Click/>

解决方案

最好的办法是将基础数据存储在会话或缓存中,然后再从另一页。不要尝试将数据存储在cookie等中。


如果将GridView传递到另一个页面,请参考



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



这里的其他方法可以使用Session但价格昂贵。



将行从一个页面传递到另一个页面,请参阅



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

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"/>

解决方案

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.


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[^]


这篇关于如何获取gridview的所有值并使用图像按钮将其传递到另一个页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆