Click here to Skip to main content
11,813,974 members (46,039 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET4
i am making school website in which i want that when new class add in database then auto fill that class in combobox of student registration form during Form load.

here is my code but it doesnot work.
can any body help me that problem?
thanks in advance.
protected void Page_Load(object sender, EventArgs e)
           SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Final Project\FinalProject\FinalProject\App_Data\Record.mdf;Integrated Security=True;User Instance=True");
           SqlCommand sc = new SqlCommand("select ClassName from SchoolClass", conn);
           SqlDataReader reader;
           reader = sc.ExecuteReader();
           DataTable dt = new DataTable();
           dt.Columns.Add("ClassName", typeof(string));

           drpclass.SelectedValue = "ClassName";
           drpclass.DataSource = dt;
Posted 7-Mar-13 3:54am
Edited 7-Mar-13 3:59am
(no name)173.3K
ThePhantomUpvoter at 7-Mar-13 9:57am
Please format your code so that it is readable and then explain what "does not work" means.
ryanb31 at 7-Mar-13 9:59am
What exactly does not work?
richcb at 7-Mar-13 11:13am
If you are using ASP.Net, then you need to call the DataBind() method after setting the datasource. That is the only thing I can see without you providing more details.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Abhinav S 265
1 Maciej Los 203
2 Palash Mondal_ 190
3 Sergey Alexandrovich Kryukov 179
0 OriginalGriff 3,877
1 KrunalRohit 2,526
2 Maciej Los 2,245
3 CPallini 2,240
4 ppolymorphe 1,750

Advertise | Privacy | Mobile
Web04 | 2.8.151002.1 | Last Updated 7 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100