Populate list from typed Dataset


This code will populate list from a typed dataset

A table in a typed dataset is used to populate a list box with employee name from the employee table. A typed dataset provides design time verification of table names and field names before the program is run.


private Employee tdsEmp;


//Call this on your button click event

PopulateListFromTDS();

private void PopulateListFromTDS()

{

string s;

int i;

//Clear Items in listBox

lstResults.Items.Clear();

for(i=0;i<=tdsEmp.EmpTDS.Count - 1;i++) //EmpTDS is table

{

// Check to see if row is flagged deleted.

if (tdsEmp.EmpTDS.RowState != DataRowState.Deleted)

{

s = tdsEmp.EmpTDS.empName.ToString();

lstResults.Items.Add(s);

}

}

}


Reference: http://angeldeeps.blogspot.com/2010/02/populate-list-from-typed-dataset.html


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: