Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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.

"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

Posted

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

Posted

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 ).

"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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...