2011-10-24 35 views
1

我有我產生一個ListView看起來像這樣在C#asp.net正從ListView控件的值

enter image description here

現在,上的點擊「添加到公文包」按鈕,我需要去雖然每個項目和電子郵件的用戶輸入數量一次。

我看見我可以做這樣的事情

foreach (var item in productFormsView.Items) 
{ 
    var somevalue = ((Form)item.DataItem).Quantity; 
} 

然而,item.DataItem是如下返回null。如何從「QUANTITY」文本框中獲取文本?

enter image description here

+2

這應該有助於http://stackoverflow.com/questions/609276/ listview-dataitem-shows-null – Candide

+0

是的,修復了它,謝謝:-) – socialMatrix

回答

1

當你點擊按鈕。 有一個新請求來到您的Web服務器。productFormsView將是init,所以該項目爲空。 當你點擊按鈕,你可以將數量數據保存在一些隱藏的字段中,並從Request.Form [「xxx」]獲取數量