Now I know why I just use MySQL and unbound objects... this SQLDataSource thing is for the birds... anyways, since I have to use it for my project, I've got a .ascx user control with a repeater attached to an SQLDataSource object. I'm trying to dynamically pass in a parameter based on a selection in a dropdown box on the parent page. However, I can't extract the value from the dropdown box because the user control binds first! How can I make the user control bind AFTER i get the value from the dropdown?
thanks
EDIT: here's some code. i'm new at this whole databound object thing, so please be gentle :)
Parent Page HTML
<asp:dropdownlist runat="server" id="ddUsers" autopostback="true"
datasourceid="sqlUsers" datatextfield="username" datavaluefield="userid" />
<asp:sqldatasource runat="server" id="sqlUsers"
selectcommand="SELECT * FROM [users]" connectionstring="<%$
ConnectionStrings:ConnectionString %>" />
....
<div id="gallery">
<ul>
<pa:photolist runat="server" id="plGallery" albumid="0" />
</ul>
</div>
....
Parent Page Codebehind
Private Sub ddUsers_DataBound(ByVal sender As Object,
ByVal e As System.EventArgs) Handles ddUsers.DataBound
Dim id As Integer = ddUsers.SelectedValue
End Sub
UC HTML
<asp:repeater runat="server" id="rPhotos" datasourceid="sqlPhotos">
<itemtemplate>
Stuff
</itemtemplate>
</asp:repeater>
<asp:sqldatasource runat="server" id="sqlPhotos"
selectcommand='SELECT * FROM PhotosWithTags
WHERE userid=@userid AND albumid=@albumid'
connectionstring="<%$ ConnectionStrings:ConnectionString %>" >
<selectparameters>
<asp:parameter name="albumid" defaultvalue="0" />
<asp:parameter name="userid" defaultvalue="1" />
</selectparameters>
</asp:sqldatasource>
UC Codebehind
Partial Public Class photolist : Inherits System.Web.UI.UserControl
Private _albumid As Integer
Public Property AlbumID() As Integer
Get
Return _albumid
End Get
Set(ByVal value As Integer)
_albumid = value
End Set
End Property
Private _userid As Integer
Public Property UserID() As Integer
Get
Return _userid
End Get
Set(ByVal value As Integer)
_userid = value
End Set
End Property
Protected Sub Page_Load(ByVal sender As Object,
ByVal e As System.EventArgs) Handles Me.Load
sqlPhotos.SelectParameters("userid").DefaultValue = UserID
sqlPhotos.SelectParameters("albumid").DefaultValue = AlbumID
End Sub
End Class
Still having problems with this :\ anyone have any ideas? thanks...