asp.net中的下拉值 [英] dropdown value in asp.net
本文介绍了asp.net中的下拉值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我在asp.net发送邮件时,它会在邮件中显示我这样的信息
DocName = css DropDownList4 = System.Web.UI.WebControls.DropDownList <当$ admin从下拉列表中选择任何值并点击提交按钮然后点击提交的值时,
i表中有dropdpwn,就像我想要的那样
DocName = css DropDownList4 = 2
代码是
when i sendig mail in asp.net it shows me in mail like thi s
DocName=css DropDownList4=System.Web.UI.WebControls.DropDownList
i have a dropdpwn in table when admin select any value from dropdown and click on submit button then value shown in mail like this what i want
DocName=css DropDownList4=2
code is
string DocName = ((Label)Repeater2.Items[i].FindControl("DocName")).Text;
string emailId = ((Label)Repeater2.Items[i].FindControl("YourEamil")).Text;
DropDownList dropdownvalue = ((DropDownList)Repeater2.Items[i].FindControl("DropDownList4"));
string docname = String.Empty;
string emailID = String.Empty;
string dropdownvalues = String.Empty;
// Next, we need to pass all three parameters to the email routine
if (DocName.ToString() != "")
{
docname = DocName.ToString();
}
else
{
docname = "Unavailable";
}
if (emailId.ToString() != "")
{
emailID = emailId.ToString();
}
else
{
emailID = "Unavailable";
}
if (dropdownvalue.SelectedItem.ToString() != "")
{
dropdownvalues = dropdownvalue.SelectedItem.ToString();
}
else
{
dropdownvalues = "Unavailable";
}
//SendEmailUsingGmail(docname.ToString(), dropdownvalue.ToString(), emailId.ToString());
SendEmailUsingGmail(DocName.ToString(), emailId.ToString(), dropdownvalue.ToString());
cmd.ExecuteNonQuery();
//try
//{
// cmd.ExecuteNonQuery();
// string emailId = ((Label)Repeater2.Items[i].FindControl("Label2")).Text;
// SendEmailUsingGmail(string emailId);
//}
//catch (Exception ex)
//{
// Supvisor.Text=(ex.Message);
//}
//try
//{
// if (DropDownListcontrol != null)
// {
// if (DropDownListcontrol.SelectedValue == "1")
// {
// //get Current EMAIL_ID from the DataKey
// string emailId = ((Label)Repeater2.Items[i].FindControl("Label2")).Text;
// //write code to send mail
// SendEmailUsingGmail(emailId);
// dt.Clear();
// dt.Dispose();
// }
// else if (DropDownListcontrol.SelectedValue == "3")
// {
// }
// }
//}
//catch (Exception ex)
//{
// Supvisor.Text = "Failed";
//}
//finally
//{
// empId = string.Empty;
//}
//UPDATE APPPROVEID IN DOCUMENTINFO TABLE
//DMSLIB.Doc myDoc = new DMSLIB.Doc();
//myDoc.MarkDocAs(Convert.ToInt16(DocId.Text), Convert.ToInt32(DropDownListcontrol.SelectedValue));
}
}
else
{
Supvisor.Text = "Error";
}
if (mySQLconnection.State == ConnectionState.Open)
{
mySQLconnection.Close();
}
}
private void SendEmailUsingGmail(string DocName, string emailId, string dropdownvalue)
{
try
{
SmtpClient smtp = new SmtpClient();
smtp.Credentials = new NetworkCredential("dfsdf4@gmail.com", "dsfsdf");
smtp.Port = 587;
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
MailMessage message = new MailMessage();
message.From = new MailAddress("dfsdf4@gmail.com");
message.To.Add(emailId);
//message.To.Add(New MailAddress(toEmailAddress));
message.Subject = "DropDownList4" + dropdownvalue;
message.Body = "DocName=" + DocName + " DropDownList4=" + dropdownvalue;
//message.Subject = "Write your email subject here";
//message.Body = "write the content of the email here";
smtp.Send(message);
}
catch (Exception ex)
{
Response.Write("Error occured: " + ex.Message.ToString());
}
}
推荐答案
使用
use
if (dropdownvalue.SelectedItem.ToString() != "")
{
dropdownvalues = dropdownvalue.SelectedValue.ToString();
}
代替
in place of
if (dropdownvalue.SelectedItem.ToString() != "")
{
dropdownvalues = dropdownvalue.SelectedItem.ToString();
}
这篇关于asp.net中的下拉值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文