2009-10-31 4 views
0

비디오 업로드를위한 웹 응용 프로그램이 있습니다. 링크에서 비디오를 표시하고 싶습니다 .i는 video.i의 비디오 ID를 전달하는 함수를 작성했습니다. 함수로. 어떻게 할 수 있습니까? 어느 누구도 나를 도울 수 있습니까? 링크 클릭시 ID를 전달

내 코드 하나 (코드가 보인다 오히려 또는 버튼) 링크에 대한 CommandArgument을 설정하는 여러 가지 방법의

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 
+0

하세요 html 또한 간단한 하이퍼 링크 또는' TheVillageIdiot

+0

user85511

답변

1

입니다.

ASPX :

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

코드 : 개인 서브 무효 GetVideos() 링크 만들기 ' 이 동영상을 GET'또는 GRID는 IT에 대한 링크 및 SET 명령 인수를 얻는 경우 lnk1.CommandArgument = ID_OF_VIDEO 최종 하위

지금 클릭 처리 :

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 
+0

리피터의 링크를 아이템 템플릿 – user85511

+0

으로 사용하고 있습니다. 그래서 코드에 링크를 얻을 수 없습니다 – user85511

+0

' 웹 응용 프로그램에서 새로운 오전 때문에 내 마음을 좀 간단히 말해 주시기 바랍니다 – user85511

관련 문제