object reference not set to an instance of an object for dropdownlist

2 posts, 0 answers
  1. Mohamed El-Sayed
    Mohamed El-Sayed avatar
    33 posts
    Member since:
    Apr 2009

    Posted 03 Mar 2013 Link to this post

    protected void RadGrid1_ItemUpdated(object sender, GridUpdatedEventArgs e)
            {
                if (Label19.Text != null && Label18.Text != null)
                {
                    System.Net.Mail.MailMessage msgMail = new System.Net.Mail.MailMessage();
     
                    msgMail.Body = (" Dear  ") + "<br/>" + "<br/>" + (" Kindly Be Noted That There Is a New Request Has Been Add From : ") + Label19.Text + "<br/>" + "<br/>" + ("Kindly Check  ");
     
                    msgMail.From = new MailAddress("");
     
                    msgMail.To.Add(DropDownList5.SelectedItem.Attributes.ToString());
     
                    msgMail.CC.Add("");
     
                    msgMail.Subject = (" Your Request Had Been :  ") + Label18.Text;
     
                    msgMail.IsBodyHtml = true;
     
                    SmtpClient smtp = new SmtpClient("");
     
                    smtp.UseDefaultCredentials = false;
     
                    NetworkCredential crdntl = new NetworkCredential("");
     
                    smtp.Credentials = crdntl;
     
                    smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
     
                    smtp.Send(msgMail);
     
                }

  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 03 Mar 2013 Link to this post

    Hello,

    if (DropDownList5 != null)
            {
                if (DropDownList5.SelectedItem != null)
                {
                    if (DropDownList5.SelectedItem.Attributes != null && DropDownList5.SelectedItem.Attributes.Count > 0)
                    {
                        string str = Convert.ToString(DropDownList5.SelectedItem.Attributes);
                        // Access your attribute here
                    }
                    else
                    {
                        // Attribute not found
                    }
                }
                else
                {
                    // Selected item not found. but some text in dropdownlist
                    string str = DropDownList5.Text;
                }
            }
            else
            {
                // Dropdown not found
            }


    Thanks,
    Jayesh Goyani
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top