CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Threaded View

  1. #1
    Join Date
    Feb 2012
    Posts
    4

    dropdownlist-how to check the value from in list in the table

    error in the below code-connot imlicitly convert type string to 'System.Web.UI.WebControls.ListItem'

    Code:
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            SqlConnection cn=myClass.DBCon();
            SqlCommand cmd=new SqlCommand("select CourseName from Course",cn);
            SqlDataReader dr=cmd.ExecuteReader();
            while (dr.Read())
            {
                if (DropDownList1.SelectedItem = dr["CourseName"].ToString())
                {
    //code
    
                }
            }
        }
    Last edited by GremlinSA; February 15th, 2012 at 03:34 AM. Reason: added code tags.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured