C#
protected void imgbtn5_Click(object sender, EventArgs e)
{
Session["theme"] = lbl5.Text;
foreach (ListViewItem item in theme5.Items)
{
Label country = (Label)item.FindControl("lblcountry");
Session["country"] = country.ToString();
Label price = (Label)item.FindControl("lblprice");
Session["price"] = price.ToString();
}
}
Here because of foreach Session Values get null again.
please suggest some other way.
aspx
<asp:ListView ID="theme5" runat="server" DataSourceID="SqlDataSource5">
<ItemTemplate>
<asp:Label ID="lblcountry" runat="server" Text='<%#Eval("Country") %>' />
</ItemTemplate>
</asp:ListView>
Here i want to get my label text value and transfer it to a session.
I guess there is problem with:
Label country = (Label)theme5.FindControl("lblcountry");
Here in country i get null value found while dubugging.
you are adding label instead of label text