nkwk Posted June 25, 2004 Posted June 25, 2004 I have problems with populating a datalist from my dataset. When I try it with a datagrid, everything seems to work fine but the datalist wont populate. I have a wizard created connection, adapter and dataset. The code: Private Sub BindList() SqlDataAdapter1.SelectCommand.CommandText = "SELECT * FROM mailinglist WHERE Firstname = 'nick'" SqlDataAdapter1.Fill(DataSet11, "mailinglist") DataList1.DataSource = DataSet11 DataList1.DataMember = "mailinglist" DataList1.DataBind() End Sub Then calling it from the page load: Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load BindList() Label5.Text = SqlDataAdapter1.SelectCommand.CommandText End Sub Quote
Arch4ngel Posted June 25, 2004 Posted June 25, 2004 Shall be working... however some minor glitch I have problems with populating a datalist from my dataset. When I try it with a datagrid, everything seems to work fine but the datalist wont populate. I have a wizard created connection, adapter and dataset. The code: Private Sub BindList() SqlDataAdapter1.SelectCommand.CommandText = "SELECT * FROM mailinglist WHERE Firstname = 'nick'" SqlDataAdapter1.Fill(DataSet11, "mailinglist") DataList1.DataSource = DataSet11 DataList1.DataMember = "mailinglist" DataList1.DataBind() End Sub Then calling it from the page load: Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load BindList() Label5.Text = SqlDataAdapter1.SelectCommand.CommandText End Sub Is your connection opened ? I recommend verifying postback in the form load if( Not IsPostBack ) ... ... ... End If Well... it seems that everything is perfect. Make sure all your table are full. It might be a problem of filling. Give me news. Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
nkwk Posted June 25, 2004 Author Posted June 25, 2004 Yeh sorry I removed that to make it less complicated. it reads: Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then BindList() End If Label5.Text = SqlDataAdapter1.SelectCommand.CommandText End Sub Quote
Arch4ngel Posted June 25, 2004 Posted June 25, 2004 Please take a look at this Did you check your DataTable to make sure all your commands fill your table correctly ? I didn't work very often with DataList but I worked a lot with DataGrid. And I know that they are a little more harder to "control" than other simpler control (eg. TextBox ). Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
wessamzeidan Posted June 26, 2004 Posted June 26, 2004 Are there any generated items in the datalist? If not then your datatable is empty. If the items are generated but they're empty, then you have a binding problem... Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
Moderators Robby Posted June 26, 2004 Moderators Posted June 26, 2004 Do you have any error handling that is ignoring errors? Run that query directly in Query Analyzer. Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.