Click here to Skip to main content
15,905,071 members
Home / Discussions / C#
   

C#

 
QuestionRe: online exam using dot net and c# - ms sql server Pin
Eddy Vluggen21-Oct-13 0:27
professionalEddy Vluggen21-Oct-13 0:27 
AnswerRe: online exam using dot net and c# - ms sql server Pin
OriginalGriff21-Oct-13 0:57
mveOriginalGriff21-Oct-13 0:57 
GeneralRe: online exam using dot net and c# - ms sql server Pin
Marco Bertschi21-Oct-13 22:41
protectorMarco Bertschi21-Oct-13 22:41 
AnswerRe: online exam using dot net and c# - ms sql server Pin
Abhinav S21-Oct-13 3:02
Abhinav S21-Oct-13 3:02 
AnswerRe: online exam using dot net and c# - ms sql server Pin
Marco Bertschi21-Oct-13 22:42
protectorMarco Bertschi21-Oct-13 22:42 
QuestionHow to pass data from 1 client to another trugh server? Pin
tdcmystere20-Oct-13 6:40
tdcmystere20-Oct-13 6:40 
AnswerRe: How to pass data from 1 client to another trugh server? Pin
OriginalGriff20-Oct-13 23:12
mveOriginalGriff20-Oct-13 23:12 
QuestionDeserialize multiple list xml and bind to Datagridview Pin
cherry chelsea18-Oct-13 20:02
cherry chelsea18-Oct-13 20:02 
This is my XML structure after serializing
XML
<?xml version="1.0"?>
    <ArrayOfTaskModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <TaskModel>
        <TaskID>Task ID 1</TaskID>
        <TaskDecs>Task Desc 1</TaskDecs>
        <TaskPerson>Task Person 1</TaskPerson>
        <TaskLong>Task Long 1</TaskLong>
        <TaskLat>Task lat 1</TaskLat>
        <TaskQuestions>
          <TaskQuestion>
            <TaskQuestionId>1</TaskQuestionId>
            <TaskQuestionType>Task Type 1</TaskQuestionType>
            <TaskQuestionTitle>Task Title 1</TaskQuestionTitle>
            <TaskQuestionDesc>Task Desc 1</TaskQuestionDesc>
            <TaskQuestionAnswers>
              <string>test</string>
              <string>test2</string>
            </TaskQuestionAnswers>
            <Answers>
              <string>test</string>
              <string>test2</string>
            </Answers>
          </TaskQuestion>
        </TaskQuestions>
      </TaskModel>
    </ArrayOfTaskModel>


Now I want to add all data from this xml file into my datagridview. I tried to use this code

XML
XmlSerializer xmlser = new XmlSerializer(typeof(List<TaskModel>));
        StreamReader srdr = new StreamReader(@"D:\myfile.xml");
        List<TaskModel> p = (List<TaskModel>)xmlser.Deserialize(srdr);
        srdr.Close();
        dataGridView1.DataSource = p;


With my TaskModel class is

C#
public class TaskModel
{
    public string TaskID { get; set; }
    public string TaskTitle { get; set; }
    public string TaskDecs { get; set; }
    public string TaskPerson { get; set; }
    public string TaskLong { get; set; }
    public string TaskLat { get; set; }
    public string TaskTime { get; set; }
    public List<TaskQuestion> TaskQuestions { get; set; }
}



And TaskQuestion.cs is

C#
public class TaskQuestion
{
    public string TaskQuestionId { get; set; }
    public string TaskQuestionType { get; set; }
    public string TaskQuestionTitle { get; set; }
    public string TaskQuestionDesc { get; set; }
    public List<string> TaskQuestionAnswers { get; set; }
    public List<string> Answers { get; set; }
}


VB
If I deserialize with the above code, I just get some element of TaskModel, except TaskQuestions because it's a list. How can I get it and bind to my datagridview? I want to display the following result into dataGridView, such as

TaskID | TaskTitle | Task Desc | TaskQuestionID | TaskQuestionType | TaskQuestionAnswers Please help me.

Questionwho can tell me how to not to use WMI to change Ip address? Pin
fengyuchun8818-Oct-13 18:13
fengyuchun8818-Oct-13 18:13 
AnswerRe: who can tell me how to not to use WMI to change Ip address? Pin
Abhinav S18-Oct-13 21:46
Abhinav S18-Oct-13 21:46 
GeneralRe: who can tell me how to not to use WMI to change Ip address? Pin
tdcmystere20-Oct-13 6:48
tdcmystere20-Oct-13 6:48 
AnswerRe: who can tell me how to not to use WMI to change Ip address? Pin
tdcmystere20-Oct-13 6:47
tdcmystere20-Oct-13 6:47 
QuestionHow to read DTD file and generate xml tags in c# Pin
Member 1034427018-Oct-13 1:27
Member 1034427018-Oct-13 1:27 
AnswerRe: How to read DTD file and generate xml tags in c# Pin
Richard MacCutchan18-Oct-13 1:54
mveRichard MacCutchan18-Oct-13 1:54 
Questionfunction call from an c++ dll in c# Pin
Willow200817-Oct-13 20:17
Willow200817-Oct-13 20:17 
SuggestionRe: function call from an c++ dll in c# Pin
Richard MacCutchan17-Oct-13 21:36
mveRichard MacCutchan17-Oct-13 21:36 
GeneralRe: function call from an c++ dll in c# Pin
Willow200817-Oct-13 23:47
Willow200817-Oct-13 23:47 
GeneralRe: function call from an c++ dll in c# Pin
Richard MacCutchan18-Oct-13 0:38
mveRichard MacCutchan18-Oct-13 0:38 
GeneralRe: function call from an c++ dll in c# Pin
Willow200818-Oct-13 0:54
Willow200818-Oct-13 0:54 
GeneralRe: function call from an c++ dll in c# Pin
OriginalGriff18-Oct-13 1:02
mveOriginalGriff18-Oct-13 1:02 
GeneralRe: function call from an c++ dll in c# Pin
Richard MacCutchan18-Oct-13 1:51
mveRichard MacCutchan18-Oct-13 1:51 
GeneralRe: function call from an c++ dll in c# Pin
_Erik_18-Oct-13 5:35
_Erik_18-Oct-13 5:35 
GeneralRe: function call from an c++ dll in c# Pin
Willow200822-Oct-13 4:02
Willow200822-Oct-13 4:02 
AnswerRe: function call from an c++ dll in c# Pin
Bernhard Hiller17-Oct-13 21:42
Bernhard Hiller17-Oct-13 21:42 
AnswerRe: function call from an c++ dll in c# Pin
OriginalGriff17-Oct-13 21:44
mveOriginalGriff17-Oct-13 21:44 

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.