Setting local variable through repeater and anchor or label
I have a repeater which fetches data from a database and shows some labels (or anchors). I have a local variable on this class which must be updated by the value retrieved from database. To cut the matter short, there is a list of labels shown by repeater, when user clicks one of them, a variable on the form (which is called swfFilename) is fetched and is passed to the flash object on the page. My code is shown below:
<ItemTemplate>
<开发者_StackOverflow;a onclick="<%#swfFileName = DataBinder.Eval(Container.DataItem, "MediaFile").ToString() %>" href="Index.aspx"> <%#DataBinder.Eval(Container.DataItem, "Text") %></a>
</ItemTemplate>
My code is not working properly and it seems that it is not assigning new value to the variable. Any help to assign the fetched value to the swfFilename
? BTW, Index.aspx is the same page that we are currently over.
Would creating a javascript function ousdide of the repeater that takes the mediaFile string as a parameter and then manipulates the swf object work?
So something along these lines ...
<script>
function manipulateFlash(mediaFile) {
// set do stuff to flash object
// assign mediaFile to flash object etc.
}
</script>
<asp:Repeater>
...
<ItemTemplate>
<a onclick="manipulateFlash('<%#DataBinder.Eval(Container.DataItem, "MediaFile").ToString() %>')" href="Index.aspx"> <%#DataBinder.Eval(Container.DataItem, "Text") %></a>
</ItemTemplate>
...
</asp:Repeater>
精彩评论