问题描述
- Datalist中Eval的值如何获取
-
<%# Eval("UserId") %>
解决方案
<tr id="producttitle">
<asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "vcproduct_title")%>' />
</tr>
protected void Add_Click(object sender, EventArgs e)
{
System.Web.UI.WebControls.Button btn = sender as System.Web.UI.WebControls.Button;
if (btn != null)
{
//string title = btn.CommandArgument.ToString();
DataListItem item = btn.NamingContainer as DataListItem;
if (item != null)
{
//find the Label and get the text:
Label lbl= item.FindControl("Label1") as Label;
string title = lbl.Text.ToString();
}
}
}
解决方案二:
想在后台取UserID的值,请详写思路和代码
时间: 2024-10-30 05:25:00