2013-05-15 46 views
0

我有問題,關於從ListPageObj傳遞值以顯示標籤上的值。 我怎樣才能獲得價值?從BLL檢索數據到標籤

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 

回答

0

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(); 
     } 
+0

它的工作原理感謝 – StackOverflowUser

+0

喜@harshit你可以幫助與此[鏈接](http://stackoverflow.com/ question/16600445/update-data-from-textbox-to-bll?noredirect = 1#comment23861803_16600445)它應該更新數據。謝謝。 – StackOverflowUser