029. aps.net中DataView中详细信息的跳转显示

点击当前页面的连接, 跳转到另一个页面, 然后进行更新删除等一系列操作

主要代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GoodsInfo.aspx.cs" Inherits="MemberManage_GoodsInfo" MaintainScrollPositionOnPostback="true" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>GridView控件中查看当前页详细信息</title>
</head>
<body style="vertical-align: middle; text-align: center">
    <form id="form1" runat="server">
    <div>
    <table style="width: 529px; height: 355px; font-size: 9pt;" cellpadding="0" cellspacing="0" align="center" border="1" bordercolor="#cccc66">
    <tr>
        <td colspan="2" style="vertical-align: top; width: 470px; text-align: center;" align="left">
            &nbsp;<br />
            <br />
            <br />
            <asp:Label ID="Label2" runat="server" Text="查询条件:"></asp:Label>
            <asp:DropDownList ID="ddlCondition" runat="server">
                <asp:ListItem Value="GoodsID">会员卡号</asp:ListItem>
                <asp:ListItem Value="GoodsTypeName">姓名</asp:ListItem>
                <asp:ListItem Value="GoodsName">性别</asp:ListItem>
                <asp:ListItem Value="StoreName">内卡号</asp:ListItem>
            </asp:DropDownList>
            &nbsp; &nbsp; &nbsp;
            <asp:Label ID="Label1" runat="server" Text="关键字:"></asp:Label>
            <asp:TextBox ID="txtKey" runat="server" Width="90px"></asp:TextBox>
            <asp:Button ID="btnSel" runat="server" Height="20px" Text="查询"
                Width="43px" OnClick="btnSel_Click" /><br /><br />
            <asp:GridView ID="gvGoodsInfo" runat="server" CellPadding="4"
                ForeColor="#333333" GridLines="None" Font-Size="9pt"
                AutoGenerateColumns="False" AllowPaging="True" PageSize="8"
               OnPageIndexChanging="gvGoodsInfo_PageIndexChanging" Width="450px">
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <EditRowStyle BackColor="#999999" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <PagerStyle BackColor="#CBCF7A" ForeColor="Black" HorizontalAlign="Right" />
                <HeaderStyle BackColor="#CBCF7A" Font-Bold="True" ForeColor="White" />
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                <Columns>
                    <asp:BoundField DataField="cardNo" HeaderText="商品ID" />
                    <asp:BoundField DataField="cardBound" HeaderText="所属类别" />
                    <asp:BoundField DataField="name" HeaderText="库存量" />
                    <asp:BoundField DataField="addr" HeaderText="商品名称" />
                     <asp:HyperLinkField HeaderText="详细信息" Text="详细信息" DataNavigateUrlFields="cardNo,cardBound"    DataNavigateUrlFormatString="EditGInfo.aspx?CardNO={0}&amp;CardBound={1}" Target="mainframe"
                        NavigateUrl="EditGInfo.aspx" > <%--这里是最重要的代码 --%>
                        <ControlStyle Font-Underline="False" ForeColor="Black" />
                        <ItemStyle Font-Underline="False" ForeColor="Black" />
                        <HeaderStyle Font-Underline="False" ForeColor="Black" />
                    </asp:HyperLinkField>
                </Columns>
            </asp:GridView><br />
        </td>
    </tr>
</table>
    </div>
    </form>
</body>
</html>

 

后台

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            sqlconn.Open();//打开数据库连接
            
            string strid = Page.Request.QueryString["CardNO"];//接收页面传值
            if (string.IsNullOrEmpty(strid))
            {
                return; 
            }
            string sqlstr = "select * from card where cardNo ='" + strid + "'";//创建查询语句
            SqlDataAdapter myda = new SqlDataAdapter(sqlstr, sqlconn);
            DataSet myds = new DataSet();
            myda.Fill(myds, "tbPicture");
            DataRowView mydrv = myds.Tables["tbPicture"].DefaultView[0];//创建表视图DataRowView
            txtGID.Text = Convert.ToString(mydrv.Row["cardNo"]);
            txtGName.Text = Convert.ToString(mydrv.Row["cardBound"]);
            txtGType.Text = Convert.ToString(mydrv.Row["name"]);
            txtGStore.Text = Convert.ToString(mydrv.Row["sex"]);
            txtGPrice.Text = Convert.ToString(mydrv.Row["addr"]);
            txtGIntro.Text = Convert.ToString(mydrv.Row["email"]) + "";
            iGPhoto.ImageUrl = Convert.ToString(mydrv.Row["remark"]);
        }
    }

 

posted on 2016-12-14 14:07  印子  阅读(260)  评论(0编辑  收藏  举报

导航