Hi , I have a listview control with Click Button. I want that if i click on a button then it should get all the data of that row on the basis of Unique ID of that Selected Row. I want it via ListView Property. I have one other method , when i click on Button of any Selected Row then it gets ID of that row in ItemCommand Event of ListView and from here I can call Sql query to get all the columns value of that ID. But I want it without doing this. Kindly help me out. Here is my code below:--
DataKeyNames="ID"
GroupItemCount="3"
OnPagePropertiesChanging="ImagesList_PagePropertiesChanging" OnItemCommand="ImagesList_ItemCommand">
No Images found.
AlternateText='<%# Eval("ServiceName") %>'
ImageUrl='<%# Eval("ServiceImage") %>' class="img-responsive" />
<%--<%#Eval("ImageTitle") %>--%>
<%#Eval("SellingPrice") %>
<%-- Add to cart--%>
<%-- --%>
AlternateText='<%# Eval("ImageTitle") %>'
ImageUrl='<%# Eval("ImageUrl") %>' class="img-responsive"/>
protected void ImagesList_ItemCommand(object sender, ListViewCommandEventArgs e)
{
if (e.CommandName == "ImgTitle")
{
string shopname = e.CommandArgument.ToString();
Response.Redirect("Item.aspx?vid="+shopname);
}
if (e.CommandName == "AddToCart")
{
int id = Convert.ToInt32(e.CommandArgument);
DataRow[] dr = dt.Select("ID="+id);
// ServiceName,ServiceImage,SellingPrice,MRP
string serviceName = dr[1]["ServiceName"].ToString();
string serviceImage = dr[1]["ServiceImage"].ToString();
float sellingPrice = Convert.ToInt64(dr[1]["SellingPrice"].ToString());
float mrp = Convert.ToInt64(dr[1]["SellingPrice"].ToString());
Response.Redirect("Shopping_Cart.aspx");
}
int index = Convert.ToInt32(e.Item.DataItemIndex);
}
Replies
Know the answer? Post it — somebody with the same question will find it here.