Hi,
i am new in ListView Control. I have a List view to show shopping products. in each data Item i put a link-button for "Add to cart" button. in my scenario clicking on this button causes ShoppingCart.Instance.AddItem("Product GUID")
to call. how can i perform that?
i set CommandName="Select"
in Link Button and performed this:
protected void ListView1_SelectedIndexChanging(object sender, ListViewSelectEventArgs e)
{
ListViewItem item = (ListViewItem)ListView1.Items[e.NewSelectedIndex];
LinkButton lb = (LinkButton)item.FindControl("LinkButtonAddAndClose");
// Here i want to get selected Product Id...
}
but always the selectedIndex is Zero!!!
How can I call ShoppingCart.Instance.AddItem("Product GUID")
and get Product Id from DataItem???
note: Eval("ID")
gets Product GUID.
Update:
I Set <%# Eval("ID")%>
for CommandArgument of LinkButton and i want somthing linke this:
protected void LinkButtonAddAndClose_Click(object sender, EventArgs e)
{
LinkButton lb = (LinkButton)sender;
var productId = new Guid(lb.CommandArgument);
ShoppingCart.Instance.AddItem(productId);
}