如何在第二页上导航datalist值 [英] how to navigate datalist values on second page

查看:85
本文介绍了如何在第二页上导航datalist值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net和c#中使用了一个数据表,它是从数据库中获取所有值,但我想当用户点击任何项目时只有那些项目详细信息导航到第二页,上面是我的代码它只移动第一行价值,但如果用户选择第二个值怎么样

datalise代码:

i have use a datalist in asp.net and c#, it is fatch all value from database, but i wanted when user click any item only those items details navigate to second page , above is my code it is moving only first row value but what about if user select 2nd value
datalise code:

<asp:DataList ID="DataList1" runat="server" Width="951px" CellPadding="3" 

            BorderStyle="None" BackColor="White" BorderColor="#E7E7FF" BorderWidth="0px" 

            DataKeyField="pid" GridLines="Horizontal" 

            onitemcommand="DataList1_ItemCommand" 

            onselectedindexchanged="DataList1_SelectedIndexChanged">
            <alternatingitemstyle borderstyle="None" backcolor="#F7F7F7" />
            <footerstyle backcolor="#B5C7DE" forecolor="#4A3C8C" />
            <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
            <itemstyle backcolor="#E7E7FF" forecolor="#4A3C8C" />
            <itemtemplate>
                <table class="style1" style="height: 188px" frame="border">
                    <tr>
                        <td rowspan="3" style="width: 209px">
                            <asp:ImageButton ID="Image1" runat="server" ImageUrl='<%# Eval("pimage") %>' Height="177px" Width="194px" />
                            <asp:PopupControlExtender ID="Image1_PopupControlExtender" runat="server" 

                                DynamicServicePath="" Enabled="True" ExtenderControlID="" 

                                TargetControlID="Image1" PopupControlID="Panel3">
                            
                        </td>
                        <td style="width: 413px; height: 47px;">
                            <asp:LinkButton ID="lbpname4" runat="server" Font-Bold="True" 

                                Font-Size="XX-Large" Text='<%# Eval("pname") %>' onclick="lbpname4_Click"> 
                        </td>
                        <td style="height: 47px">
                             <asp:Label ID="Label10" runat="server" Text="Rs. ">
                             <asp:Label ID="lbpprice5" runat="server" Font-Size="Large" Text='<%# Eval("pprice") %>'>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 413px">
                            <asp:Label ID="lbcateg8" runat="server" Text='<%# Eval("categ") %>'>
                             
                            <asp:Label ID="lbpdetails6" runat="server" Text='<%# Eval("pdetails") %>'>
                            <br />
                        </td>
                        <td rowspan="2">
                            <asp:Panel ID="Panel2" runat="server" BorderStyle="None" Height="134px">
                                Seller's Name 
                                <asp:Label ID="lbuname0" runat="server" Text='<%# Eval("uname") %>'>
                                <br />
                                <br />
                                Contect Details  
                                <asp:Label ID="lbcontect2" runat="server" Text='<%# Eval("ucontect") %>'>
                                <br />
                                <br />
                                Email id  
                                <asp:Label ID="lbemail3" runat="server" Text='<%# Eval("uemail") %>'>
                                <br />
                                <br />
                                <asp:Label ID="lbpid9" runat="server" Text='<%# Eval("pid") %>' Visible="False">
                            
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 413px; height: 69px;">
                            <asp:Label ID="lbulocation1" runat="server" Text='<%# Eval("ulocation") %>'>
                        </td>
                    </tr>
                </table>
                <br />
            </itemtemplate>
            <SelectedItemStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />







这是逻辑代码:




and this is logical code :

protected void lbpname4_Click(object sender, EventArgs e)
   {
       SqlCommand cmd = new SqlCommand("Select * from AddPost", con);
       con.Open();
       SqlDataReader dr = cmd.ExecuteReader();
       while (dr.Read())
       {

               Session["pname"] = dr["pname"];
               Response.Redirect("Cate.aspx");
       }
       con.Close();
   }

推荐答案

所以,基本上你是从 DataReader 总是如此。你需要改变你的逻辑。
So, basically you are reading the first row value from the DataReader always. You need to change your logic.


这篇关于如何在第二页上导航datalist值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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