in my web application i have a datalist in that i am binding some images. in datalist itemcommand event i write code some code which is not firing, i mean the itemcomand event is not firing. can u help me. this is my source code
DataList control:
<asp:DataList ID="DLQuickVideos" runat="server" RepeatColumns ="2" CellPadding="0" CellSpacing="0" OnItemCommand="DLQuickVideos_ItemCommand" >
<ItemTemplate>
<asp:ImageButton ID="imgbtn" runat="server" ImageUrl='<%# "../Trailorvideos/"+ Eval("SnapShot") %>' CommandArgument='<%# Eval("video")+"|"+Eval("videoid") %>' CausesValidation="false" Width="111px" Height="83px" BorderStyle="double" BorderWidth="4px" BorderColor="#A70202" />
</ItemTemplate>
</asp:DataList>
Event Handler:
protected void DLQuickVideos_ItemCommand(object source, DataListCommandEventArgs e)
{
try
{
string eval = e.CommandArgument.ToString();
int k = eval.IndexOf("|");
videoname = eval.Substring(0, k);
videoid = eval.Substring(k + 1);
string move = Request.QueryString["movie"].ToString();
if (Request.Browser.Browser == "IE")
{
dvplayer.InnerHtml = "<object id='player' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' name='player' width='500' height='350'> <param name='movie' value='player-viral.swf' /> <param name='allowfullscreen' value='true' /> <param name='allowscriptaccess' value='always' /> <param name='flashvars' value='file=~/User/Trailorvideos/" + videoname + "&autostart=true' /> <p><a href='http://get.adobe.com/flashplayer'>Get Flash</a> to see this player.</p> </object>";
}
else
{
dvplayer.InnerHtml = "<object type='application/x-shockwave-flash' data='player-viral.swf' width='500' height='350'> <param name='movie' value='player-viral.swf' /> <param name='allowfullscreen' value='true' /> <param name='allowscriptaccess' value='always' /> <param name='flashvars' value='file=~/User/Trailorvideos/" + videoname + "&autostart=true' /> <p><a href='http://get.adobe.com/flashplayer'>Get Flash</a> to see this player.</p> </object>";
}
GetQuickList(videoid);
}
catch (Exception ex)
{
}
}
above code .cs code
You have posted that this is your page load event:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) //this IF statement is what prevents re-binding on PostBack
{
GetQuickList(videoid, moviename);
}
else
{
GetQuickList(videoid, moviename)
}
}
This will not work. You must not databind on post back. Otherwise any pending event handler requests are cancelled.
You must remove the else part of this if statement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With