Rank: Member Groups: Member
Joined: 6/12/2008 Posts: 14 Points: -608 Location: Brazil
|
HTML
<ASPNetAudio:Audio ID="MediaPlayer" AutoPlay="true" runat="server" Volume="50"></ASPNetAudio:Audio> <asp:Panel ID="Panel1" runat="server"></asp:Panel>
<ASPNetMediaGUI:PlayList ID="PlayList" runat="server" width="96%" MediaPlayer="MediaPlayer" ShowHeader="False" AutoGenerateColumns="False" PlayState="Play" SelectedTrack="1" ontrackchangeevent="PlayList_TrackChangeEvent" DataSourceID="ObjectDataSource1" onrowdatabound="PlayList_RowDataBound" LoopPlayList="True" ondatabound="PlayList_DataBound"> <SelectedRowStyle BackColor="#bb17ff" /> <AlternatingRowStyle BackColor="#BFBFBF" /> <Columns> <asp:TemplateField ShowHeader="False"> <ItemTemplate> <asp:LinkButton CssClass="FonteTela" ID="TrackSelectButton" runat="server" CausesValidation="False" CommandName="Select" Text='<%# Eval("artist") +" - "+ Eval("name") %>' CommandArgument='<%# Eval("url") %>' OnCommand="HandleClick"> </asp:LinkButton> </ItemTemplate> </asp:TemplateField> </Columns> </ASPNetMediaGUI:PlayList>
Points of consideration:
⢠If ASPNetMediaGUI:PlayList inherits from aspnet GridView, the expected way of bind this control should be setting the datasource and calling databind() method: PlayList.DataSource = MyClass.MyDataTableMethod; PlayList.DataBind(); ⢠We expect to do this just if not page is postback. The ViewState property of the gridview should serialize the databound information. ⢠Is very important not call the databind method every time the page post back. Thatâs the problem!
The way I put it running:
⢠I call the DataBind() method on the Page Load. ⢠The only way it works is when I call this method outside of the if(!Page.IsPostBack) setence making a trip to the database everysingle click on the page, etc.
void DataBind() { if (pkArtist != null) { ObjectDataSource ObjectDataSource1 = new ObjectDataSource(); ObjectDataSource1.ID = "ObjectDataSource1"; ObjectDataSource1.TypeName = "business.Player"; ObjectDataSource1.SelectMethod = "ListenByArtist"; ObjectDataSource1.SelectParameters.Add(new Parameter("pkArtist", TypeCode.Int32, pkArtist)); this.Panel1.Controls.Add(ObjectDataSource1); } else { PlayList.PlayListTracks.Clear();
ASPNetMediaGUI.PlayListTrack track = new ASPNetMediaGUI.PlayListTrack(); track.Name = "a"; track.URL = "b";
PlayList.PlayListTracks.Add(track); PlayList.DataSourceID = ""; PlayList.Columns.Clear(); } }
The necessities:
⢠NOT use ObjectDataSource component to bind data to the Playlist. ⢠Use the Playlist component pretty much like an usual GridView, calling DataSource property and DataBind method. ⢠The ViewState of the Playlist component MUST work as an usual GridView.
|