从数据网格视图在ASP页面之间传递值 [英] pass value between asp pages from data grid view

查看:101
本文介绍了从数据网格视图在ASP页面之间传递值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何将ASP页面之间的值作为查询ID从页面1的数据网格视图传递到其他页面2的数据网格视图.

How we can pass value between asp pages from data grid view in page 1 to data grid view in other page 2 as query id .

推荐答案

使用会话 [ QueryString [ ^ ]


p:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:GridView ID="GridView1" runat="server" BackColor="White"

                        BorderColor="#DEDFDE" BorderStyle="None"

    BorderWidth="1px" CellPadding="4"

                        ForeColor="Black" GridLines="Vertical" onrowcommand="GridView1_RowCommand"

                        Width="595px" AllowPaging="True"

                        onpageindexchanging="GridView1_PageIndexChanging"

    PageSize="6">
                        <PagerSettings FirstPageText="First" LastPageText="Last"

                            Mode="NextPreviousFirstLast" NextPageText="Next" PreviousPageText="Prev" />
                        <RowStyle BackColor="#F7F7DE" />
                        <Columns>
                            <asp:ButtonField ButtonType="Button" CommandName="Edit" HeaderText="Edit"

                                ShowHeader="True" Text="Edit" />
                        </Columns>
                        <FooterStyle BackColor="#CCCC99" />
                        <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
                        <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
                        <AlternatingRowStyle BackColor="White" />
                    </asp:GridView>





page.cs code


 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Edit")
        {
            int x = Convert.ToInt32(e.CommandArgument.ToString());
            Class1.index = x;
            Session["index"] = x;
            Response.Redirect("Update.aspx?ID=" +x);
        }
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        GridView1.DataBind();

    }


这篇关于从数据网格视图在ASP页面之间传递值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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