将文本框与包含2条以上记录的数据绑定 [英] binding textbox with data with more than 2 records

查看:40
本文介绍了将文本框与包含2条以上记录的数据绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个名为Employee_Email的表,其列名称为Email_Id,并且该表中有6条记录,例如
wasif@gmail.com
Sam@gmail.com
Sally@gmail.com
Rukh@gmail.com
Sunny@gmail.com
anc@gmail.com

在前端,我有一个文本框,如textEmail.
现在,我必须将所有电子邮件与文本框绑定在一起,并用;"分隔.

像Sam@gmail.com; Sally@gmail.com;
我做了这样的事情.

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.

void SeniorsMail(string dept)
   {
       dt = lr.GetSeniorsEmail(dept);
       if (dt.Rows.Count > 0)
       {
               txtMailTo.Text = dt.Rows[0]["OffEmail"].ToString();
       }
   }




请提供使用DataTable的解决方案.


谢谢你
mohammad wasif




Please give a solution for that using DataTable.


Thanking You
mohammad wasif

推荐答案

这里出了什么问题?

您是否尝试遍历它?
Whats the issue here?

Did you try looping through it?
if (dt.Rows.Count > 0)
{
   string allEmailIDinOne = string.Empty;
   foreach(DataRow dr in dt.Rows)
   {
     allEmailIDinOne += dr["Email_Id"].ToString() + ";";
   }
   txtMailTo.Text = allEmailIDinOne ;
}


这篇关于将文本框与包含2条以上记录的数据绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆