DropdownList DataBinding

Reply

Join Date: Mar 2008
Posts: 324
Reputation: sonia sardana has a little shameless behaviour in the past 
Solved Threads: 7
sonia sardana sonia sardana is offline Offline
Posting Whiz

DropdownList DataBinding

 
-1
  #1
Oct 23rd, 2009
  1. <connectionStrings>
  2. <add name="ConnectionString" connectionString="Data Source=(local);Initial catalog=sonia;User ID=sonia;Password=sonia;" providerName="System.Data.SqlClient"/>
  3. </connectionStrings>


  1. public partial class Frmgrid : System.Web.UI.Page
  2. {
  3. SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
  4. SqlDataAdapter da;
  5. DataSet ds;
  6.  
  7. protected void Page_Load(object sender, EventArgs e)
  8. {
  9. try
  10. {
  11. da = new SqlDataAdapter("SELECT * FROM Products", conn);
  12. da.Fill(ds, "tb1");
  13. DropDownList1.DataSource = ds.Tables["tb1"];
  14. DropDownList1.DataBind();
  15. }
  16. catch (Exception ex)
  17. {
  18. Response.Write(ex.Message.ToString());
  19. }
  20. }
  21. }


ERROR is dere while executing the line da.Fill(ds, "tb1");
"Value cannot be null.\r\nParameter name: dataSet"
Last edited by sonia sardana; Oct 23rd, 2009 at 1:40 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 44
Reputation: guru_sarkar is an unknown quantity at this point 
Solved Threads: 6
guru_sarkar guru_sarkar is offline Offline
Light Poster
 
0
  #2
Oct 23rd, 2009
You must intialize ds
e.g. DataSet ds = new DataSet();

Check this eg:
http://msdn.microsoft.com/en-us/libr...8z(VS.80).aspx
Reply With Quote Quick reply to this message  
Reply

Message:




Views: 405 | Replies: 1
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC