Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
IEnumerable<alist> objApproverlist = objservice.GetAlist(txtA.Text, 1, "Y", 403, "S", "N", 2257, "N");


objApproverlist to datatable or dataset...
Posted
Updated 26-Aug-15 1:39am
v3
Comments
Maciej Los 26-Aug-15 7:48am    
What have you tried? Where are you stuck?
Sathish km 26-Aug-15 7:58am    
IEnumerable objBankList = GetAList(1, "S", "A", 72, 523, null);

if (dsDetails == null || dsDetails.Tables[0].Rows.Count == 0)
{
DataRow drDetails = dsDetails.Tables[0].NewRow();
drDetails["BName"] = "No Records";
drDetails["BCode"] = 0;
drDetails.Tables[0].Rows.InsertAt(drDetails , 0);
}
else if (dsDetails.Tables[0].Rows.Count > 1)
{
DataRow drDetails = dsDetails.Tables[0].NewRow();

drDetails["BName"] = "<-- Select -->";
drDetails["Code"] = 0;
dsDetails.Tables[0].Rows.InsertAt(drDetails, 0);

}
//cb1.DisplayMember = "BName";
//cb1.ValueMember = "BCode";
//cb1.DataSource = dsDetails.Tables[0];

I want to use objApproverlist instead of dsGetails to cb1.datasource
cb1.DisplayMember = "Description";
cb1.ValueMember = "ACode";
cb1.DataSource = objApproverlist;
F-ES Sitecore 26-Aug-15 7:52am    
Depending on what you are doing with the dataset you might not need to convert it at all. GridViews, Repeaters etc can be bound direct to an IEnumerable.

1 solution

Please, read my comment to the question. You did not provide enough information to post exact answer. So...

There's IEnumerable(Of T).CopyToDataTable Method [^] which you can use.
 
Share this answer
 
Comments
Sathish km 26-Aug-15 7:53am    
IEnumerable<alist> objBankList = GetAList(1, "S", "A", 72, 523, null);

if (dsDetails == null || dsDetails.Tables[0].Rows.Count == 0)
{
DataRow drDetails = dsDetails.Tables[0].NewRow();
drDetails["BName"] = "No Records";
drDetails["BCode"] = 0;
drDetails.Tables[0].Rows.InsertAt(drDetails , 0);
}
else if (dsDetails.Tables[0].Rows.Count > 1)
{
DataRow drDetails = dsDetails.Tables[0].NewRow();

drDetails["BName"] = "<-- Select -->";
drDetails["Code"] = 0;
dsDetails.Tables[0].Rows.InsertAt(drDetails, 0);

}
//cb1.DisplayMember = "BName";
//cb1.ValueMember = "BCode";
//cb1.DataSource = dsDetails.Tables[0];


cb1.DisplayMember = "Description";
cb1.ValueMember = "ACode";
cb1.DataSource = objApproverlist;

I want to use objApproverlist instead of dsGetails to cb1.datasource
Sathish km 26-Aug-15 7:54am    
i need code for IF condition..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900