Click here to Skip to main content
15,918,742 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Interface Pin
Yusuf20-Aug-10 3:53
Yusuf20-Aug-10 3:53 
AnswerRe: Interface Pin
Eaverae23-Aug-10 0:49
Eaverae23-Aug-10 0:49 
QuestionUnable to connect to any of the specified MySQL hosts in asp.net2010 vista Pin
Piyush Vardhan Singh19-Aug-10 5:18
Piyush Vardhan Singh19-Aug-10 5:18 
AnswerRe: Unable to connect to any of the specified MySQL hosts in asp.net2010 vista Pin
Yusuf19-Aug-10 10:27
Yusuf19-Aug-10 10:27 
Questionimage display problem Pin
Dhyanga19-Aug-10 4:41
Dhyanga19-Aug-10 4:41 
AnswerRe: image display problem PinPopular
Al-Farooque Shubho19-Aug-10 5:41
Al-Farooque Shubho19-Aug-10 5:41 
GeneralRe: image display problem Pin
Dhyanga19-Aug-10 6:04
Dhyanga19-Aug-10 6:04 
QuestionReading data from ListView into generic list Pin
kstxx19-Aug-10 2:20
kstxx19-Aug-10 2:20 
I have a ListView which is filled by generic list of type MyClass. I can easily bind data from this list into ListView. But I have problems with reading data in opposite direction. This is my class:


public class MyClass 
{ 
    public int id { get; set; } 
    public string name { get; set; } 
} 


I have also generic list of type MyClass:

List<MyTest> list = new List<MyTest>(); 


Finally I bind data to ListView this way:

ListView1.DataSource = list; 
ListView1.DataBind(); 


My ListView template:


<asp:ListView runat="server" ID="ListView1"> 
  <LayoutTemplate> 
    <table runat="server" id="table1" > 
      <tr runat="server" id="itemPlaceholder" ></tr> 
    </table> 
  </LayoutTemplate> 
  <ItemTemplate> 
    <tr id="tr" runat="server"> 
        <td id="td1" runat="server"> 
            <asp:TextBox ID="tb1" runat="server" Text='<%#Eval("id") %>' /> 
        </td> 
        <td id="td2" runat="server"> 
            <asp:TextBox ID="tb2" runat="server" Text='<%#Eval("name") %>' /> 
        </td> 
    </tr> 
  </ItemTemplate> 
</asp:ListView>


How can I read data from ListView into my List list?

The operation of reading ListView data into List generic list should begin after clicking the button "GetData".

I saw the following advice:

List<MyClass> list = ListView1.Items 
                              .Select(lvi=>lvi.DataItem as MyClass) 
                              .ToList();


but it does not work - the DataItem property of each Item of ListView has null value.



The point is that I have generic list with data. I am binding this data into ListView which can be edited by user. After that after click Save or GetData data from ListView is read into generic list of MyClass type.
Questionkey press in asp:TextBox Pin
dittu718-Aug-10 22:20
dittu718-Aug-10 22:20 
AnswerRe: key press in asp:TextBox Pin
Blue_Boy19-Aug-10 0:26
Blue_Boy19-Aug-10 0:26 
QuestionStatic method Pin
future383918-Aug-10 19:34
future383918-Aug-10 19:34 
AnswerRe: Static method Pin
Rajendra Prasad Panchati18-Aug-10 20:54
Rajendra Prasad Panchati18-Aug-10 20:54 
AnswerRe: Static method Pin
R. Giskard Reventlov18-Aug-10 21:25
R. Giskard Reventlov18-Aug-10 21:25 
AnswerRe: Static method Pin
Arun Jacob18-Aug-10 22:05
Arun Jacob18-Aug-10 22:05 
QuestionStructure Maps/Dependency Injection Pin
AndyASPVB18-Aug-10 12:26
AndyASPVB18-Aug-10 12:26 
AnswerRe: Structure Maps/Dependency Injection Pin
R. Giskard Reventlov18-Aug-10 21:26
R. Giskard Reventlov18-Aug-10 21:26 
GeneralRe: Structure Maps/Dependency Injection Pin
AndyASPVB18-Aug-10 21:31
AndyASPVB18-Aug-10 21:31 
Questioncheckbox problem Pin
Dhyanga18-Aug-10 5:38
Dhyanga18-Aug-10 5:38 
AnswerRe: checkbox problem Pin
Sandeep Mewara18-Aug-10 6:31
mveSandeep Mewara18-Aug-10 6:31 
AnswerRe: checkbox problem Pin
raju melveetilpurayil18-Aug-10 6:35
professionalraju melveetilpurayil18-Aug-10 6:35 
AnswerRe: checkbox problem Pin
Ennis Ray Lynch, Jr.18-Aug-10 6:46
Ennis Ray Lynch, Jr.18-Aug-10 6:46 
GeneralRe: checkbox problem Pin
Dhyanga18-Aug-10 7:45
Dhyanga18-Aug-10 7:45 
AnswerRe: checkbox problem Pin
richardqiaolixin18-Aug-10 16:30
richardqiaolixin18-Aug-10 16:30 
AnswerRe: checkbox problem Pin
Rajendra Prasad Panchati18-Aug-10 19:27
Rajendra Prasad Panchati18-Aug-10 19:27 
GeneralRe: checkbox problem Pin
Dhyanga19-Aug-10 3:42
Dhyanga19-Aug-10 3:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.