如何在C#中的foreach循环中获取多个表的下拉选择值 [英] How to get dropdown selected value of multiple table in foreach loop in C#

查看:73
本文介绍了如何在C#中的foreach循环中获取多个表的下拉选择值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有7个表,每行包含下拉列表和文本框,单击该按钮上的单个按钮第一个数据保存到我已完成的数据库但同时我必须将所有这些填充行邮寄到邮件中。但我无法在发送邮件时读取每一行的下拉值。

i只能向一行表发送邮件,但我必须将邮件发送到所有填充的行..



我的尝试:



I have 7 table , each row contain dropdown and textbox and a single button on clicking that button first data save to database that i have done but at the same time i have to mail all these fill row in mail. but i am unable to read dropdown value of each row during sending mail.
i am able to send mail to only one row of table but i have to send mail to all row that is fill..

What I have tried:

if (ddlctype.Text != "Select")
{
    string body = "<table  border=" + 1 + " cellpadding=" + 5 + " cellspacing=" + 0 + " ><tr><th>Client Type</th>" + " " + "<th>Date</th>" + " " + "<th>TME</th>" + " " + "<th>Area</th>" + " " + "<th>Company Name</th>" + " " + "<th>Client Name</th>" + " " + "<th>Mobile</th>" + " " + "<th>Email</th>" + " " + "<th>Address</th>" + " " + "<th>Landmark</th>" + " " + "<th>Current presence/Appoint</th>" + " " + "<th>Status</th>" + " " + "<th>Result</th>" + " " + "<th>Comments</th>" + "<tr/><tr>" +
         "<td>" + ddlctype.Text + "</td>" +
         "<td>" + txtDate.Text + "</td>" +
         "<td>" + ddltme.Text + "</td>" +
         "<td>" + txtarea.Text + "</td>" +
         "<td>" + txtcname.Text + "</td>" +
         "<td>" + txtclientname.Text + "</td>" +
         "<td>" + txtmobile.Text + "</td>" +

         "<td>" + txtemail.Text + "</td>" +
         "<td>" + txtaddress.Text + "</td>" +
         "<td>" + txtlandmark.Text + "</td>" +
         "<td>" + txtcurr.Text + "</td>" +

         "<td>" + ddlstatus.Text + "</td>" +
         "<td>" + ddlresult.Text + "</td>" +
         "<td>" + txtcomment.Text + "</td>" +
          "</tr></table>";

    mail.Body = body;
}

推荐答案

简单,如果该表是asp.net表,您可以使用以下类型的进程:



ISimple, if that table is asp.net table you can use following type of process:

foreach (TableRow row in tbl.Rows)
           {
               foreach (Table cell in row.Cells)
               {
                   foreach (Control ctrl in cell.Controls)
                   {
                       //CONTROL IS TEXBOXT: EXTRACT VALUES//
                       if (ctrl is TextBox)
                      {
                          TextBox txt = (TextBox)ctrl;
                        Label lbl = new Label();
                        lbl.Text = txt.Text;
                        PlaceHolder1.Controls.Add(lbl);

                        }
                   }
               }
           }


这篇关于如何在C#中的foreach循环中获取多个表的下拉选择值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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