DataList绑定了productid,productname,添加了<asp:LinkButton>列表示购买
当点击LinkButton时就购买productid的商品,然后进行操作
我的问题是:
如何判断所点击的LinkButton是在哪个productid上?
也就是如何得到这个productid?
多谢!
当点击LinkButton时就购买productid的商品,然后进行操作
我的问题是:
如何判断所点击的LinkButton是在哪个productid上?
也就是如何得到这个productid?
多谢!
<asp:LinkButton id="linkbutton" commandargument='<%# DataBinder.Eval(Container.DataItem, "productid") %>' runat="server" text="link" onclick="DoLink">
</asp:LinkButton>
..
public void DoLink(object sender, System.EventArgs e)
{
LinkButton d=(LinkButton)sender;
string productid=d.CommandArgument;
}
e.item.itemindex
void Item_Command(Object sender, DataListCommandEventArgs e)
{
// Set the SelectedIndex property to select an item in the DataList.
ItemsList.SelectedIndex = e.Item.ItemIndex; // Rebind the data source to the DataList to refresh the control.
ItemsList.DataSource = CreateDataSource();
ItemsList.DataBind(); }
LinkButton.text绑定productname
LinkButton.CommandArgument绑定productidPrivate Sub DataList1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles DataList1.ItemCommand
事件中处理商品购买
在popo.aspx页:
string productid=Request.QueryString["productid"].ToString;