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">
</asp:PopupControlExtender>
</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"> </asp:LinkButton>
</td>
<td style="height: 47px">
<asp:Label ID="Label10" runat="server" Text="Rs. "></asp:Label>
<asp:Label ID="lbpprice5" runat="server" Font-Size="Large" Text='<%# Eval("pprice") %>'></asp:Label>
</td>
</tr>
<tr>
<td style="width: 413px">
<asp:Label ID="lbcateg8" runat="server" Text='<%# Eval("categ") %>'></asp:Label>
<asp:Label ID="lbpdetails6" runat="server" Text='<%# Eval("pdetails") %>'></asp:Label>
<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") %>'></asp:Label>
<br />
<br />
Contect Details
<asp:Label ID="lbcontect2" runat="server" Text='<%# Eval("ucontect") %>'></asp:Label>
<br />
<br />
Email id
<asp:Label ID="lbemail3" runat="server" Text='<%# Eval("uemail") %>'></asp:Label>
<br />
<br />
<asp:Label ID="lbpid9" runat="server" Text='<%# Eval("pid") %>' Visible="False"></asp:Label>
</asp:Panel>
</td>
</tr>
<tr>
<td style="width: 413px; height: 69px;">
<asp:Label ID="lbulocation1" runat="server" Text='<%# Eval("ulocation") %>'></asp:Label>
</td>
</tr>
</table>
<br />
</ItemTemplate>
<SelectedItemStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
</asp:DataList>
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();
}