Click here to Skip to main content
15,939,065 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have a table as Employee_Email having column name Email_Id and there are 6 records in this table like
wasif@gmail.com
Sam@gmail.com
Sally@gmail.com
Rukh@gmail.com
Sunny@gmail.com
anc@gmail.com

and in front end i am having a textbox as textEmail.
Now I have to bind all emails with textbox seperated by ";".

like Sam@gmail.com;Sally@gmail.com;
I did something like this.
C#
void SeniorsMail(string dept)
   {
       dt = lr.GetSeniorsEmail(dept);
       if (dt.Rows.Count > 0)
       {
               txtMailTo.Text = dt.Rows[0]["OffEmail"].ToString();
       }
   }



Please give a solution for that using DataTable.


Thanking You
mohammad wasif
Posted

1 solution

Whats the issue here?

Did you try looping through it?
C#
if (dt.Rows.Count > 0)
{
   string allEmailIDinOne = string.Empty;
   foreach(DataRow dr in dt.Rows)
   {
     allEmailIDinOne += dr["Email_Id"].ToString() + ";";
   }
   txtMailTo.Text = allEmailIDinOne ;
}
 
Share this answer
 
Comments
Mohd Wasif 7-Mar-11 1:17am    
thanks
Sandeep Mewara 7-Mar-11 1:24am    
I just noticed you never close a question. You have posted some 56 questions by now but have hardly accepted any answer till date. Why so? If someone helps you and it resolves your issue you should close the question accepting that answer. What say?
Mohd Wasif 7-Mar-11 5:31am    
Please Let me know how to close the Question?
I don't know Please Help.

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