access page level variable in datagrid

Last post 05-07-2007 1:31 AM by Allen Chen – MSFT. 1 replies.

Sort Posts:

  • access page level variable in datagrid

    05-03-2007, 12:20 PM
    • Loading...
    • mayuresh_s
    • Joined on 02-05-2007, 10:42 PM
    • USA
    • Posts 29

    I have a flash object in a repeater control. I need to get the whole web URL for every flash file in the Item Data Bound event. I get the file name from database and in the Item Data Bound method create the whole HTTP web address for the flash file. This is then assigned to sSWFFileImageName. But what happens is that this page level variable sSWFFileImageName restores only the last read value. I cannot move this page level variable inside Item Data Bound method, becoz it gives an error saying "Cannot access this variable" as its a local variable. I need the unique value of the flash image bound to every row.

    <asp:Repeater id="rptPreProcIllustration" runat="server">
            <ItemTemplate>  
            
                <object type="application/x-shockwave-flash" data="<%=sSWFFileImageName %>" width="280" height="240">
                    <param name="movie" value="<%=sSWFFileImageName %>">
                    <img src="<%=sSWFFileImageName %>" alt="ALT text for replacment image" width="280" height="240">
                </object>                            
                                                      
           </ItemTemplate>
    </asp:Repeater>

  • Re: access page level variable in datagrid

    05-07-2007, 1:31 AM
    Answer

    Hi:

      You can just change this <object> tag to <asp:Literal ID="Literal1" runat="server".....>. In Repeater_ItemDataBound event handler, assign this to the text of literal:

       DataRowView drv = (DataRowView)e.Item.DataItem;

     Literal l=(Literal)e.Item.FindControl("Literal1");

    l.Text="<object type="application/x-shockwave-flash........" + drv["DataField_in_Your_DataBase"].ToString() + "..........</object>";

     

    If it doesn't work, please inform us.

    Regards

    Sincerely,
    Allen Chen
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 1 (2 items)
Microsoft Communities
Page view counter