tags:

views:

47

answers:

1

i have a web application for video uploading,In that i want to show the video in the link click.i wrote a function for to show the video.i want to pass the id of video into the function .How can i Do that? Can any one help Me?

This is my code

    Private Function
         GetSpecificVideo(ByVal i As Object) As
         DataTable
         'pass the id of the video
         Dim connectionString As String = 
         ConfigurationManager.ConnectionStrings("UploadConnectionString")
          .ConnectionString
         Dim adapter As New SqlDataAdapter("SELECT FileName,
                            FileID,FilePath " + "FROM FileM WHERE
                            FileID = @FileID", connectionString)
                            adapter.SelectCommand.Parameters.Add("@FileID",
                         SqlDbType.Int).Value = DirectCast(i, Integer)
         Dim table As New DataTable()
         adapter.Fill(table)
         Return table
    End Function

Protected Sub ButtonShowVideo_Click(ByVal sender As System.Object, 
       ByVal e As System.EventArgs) Handles ButtonShowVideo.Click

    Repeater1.DataSource = GetSpecificVideo(****here i want to get the ID****)
    'the video id (2 is example)

    Repeater1.DataBind()
End Sub
+1  A: 

of the many ways one is to set CommandArgument for the link (or rather button as your code seems).

ASPX:

<ItemTemplate>
    <asp:LinkButton ID="lnkVideo" runat="server" 
              CommandArgument='<%# Eval("VideoID")%>' 
              OnClick="ButtonShowVideo_Click">Watch Video</asp:LinkButton>
</ItemTemplate>

Code: private sub void GetVideos() 'GET VIDEO(S) 'CREATE LINKS OR IF IN GRID GET LINKS AND SET COMMAND ARGUMENT FOR IT lnk1.CommandArgument = ID_OF_VIDEO end sub

now handle click:

Protected Sub ButtonShowVideo_Click(ByVal sender As System.Object, 
       ByVal e As System.EventArgs) Handles ButtonShowVideo.Click

    var btn = sender as Button 'or Link or LinkButton

    if(btn is not null) then
        if(NOT string.IsNullOrEmpty(btn.CommandArgument)) then
               var vid = Convert.ToInt32(btn.CommandArgument)
                Repeater1.DataSource = GetSpecificVideo(vid)
                Repeater1.DataBind()
        end if
    end if
End Sub
TheVillageIdiot
i using the link in repeater,as item template
so i can't get the link in code
if you don't mind please tell me briefly,because i am new in web applications
is it c#? var btn = sender as Button 'or Link or LinkButton
yes it is C# but you can substiture `var` with `Button` or `LinkButton`
TheVillageIdiot