【问题标题】:Retrieving Data from BLL to labels将数据从 BLL 检索到标签
【发布时间】:2013-05-09 16:46:41
【问题描述】:

我对从 ListPageObj 传递值以在标签上显示值有疑问。 我怎样才能获得价值?

BLL

public List<ListPageObj> MyList(int ItemID)
        {
            return (from a in ctx.Item where a.ItemID == ItemIDselect new ListPageObj
            {
                Item1= a.Item1,
                Item2= a.Item2,
                Item3= a.Item3
            }).ToList<ListPageObj>();
        }

ListPageObj

public string Item1
    { get; set; }

    public string Item2
    { get; set; }

    public string Item3
    { get; set; }

aspx

<asp:label id="label1" runat="server" />
<asp:label id="label2" runat="server" />
<asp:label id="label3" runat="server" />

aspx.cs ?

 //code to retrieve item1, item2, item3 value from BLL
 label1.Text = ListPageObj.Item1; // gives me null value
 label2.Text = ListPageObj.Item2; // gives me null value
 label3.Text = ListPageObj.Item3; // gives me null value

【问题讨论】:

    标签: c# list object label bll


    【解决方案1】:

    aspx.cs 页面

    ListPageObj ObjItem = ClassName.MyList(ItemID);
    
    label1.Text = ObjItem.Item1; 
    label2.Text = ObjItem.Item2; 
    label3.Text = ObjItem.Item3; 
    

    BLL

    public ListPageObj MyList(int ItemID)
            {
                return (from a in ctx.Item where a.ItemID == ItemIDselect new ListPageObj
                {
                    Item1= a.Item1,
                    Item2= a.Item2,
                    Item3= a.Item3
                }).FirstOrDefault();
            }
    

    【讨论】:

    • 嗨@harshit 你能帮忙解决这个link 它应该更新数据。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2018-08-27
    • 1970-01-01
    • 1970-01-01
    • 2013-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多