Datalist中Eval的值如何获取



<%# Eval("UserId") %>

2个回答

 <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的值,请详写思路和代码

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问