button event in nested repeater - asp.net

I am using nested repeater and child repeater has a user control in it.
<asp:repeater>
<asp:repeater>
<uc:userControl />
</asp:repeater>
</asp:repeater>
UserControl saves the information in database and raise the itemsaved event passing success message as event args.
I do have public event in usercontrol that will be raised but there is no way I can bind that event in the main page. (it would be really good if I can do that).
But I found another way to handle it in parent repeater's itemcommand. First it will fire usercontrol's button event and then repeater's itemcommand. I can recognize that usercontrol's event in itemcommand but how do I pass whether the information saved successfully or not? Is there any way I can pass true/false(successful save or not) from usercontrol's button event to itemcommand event?

You can handle your UserControl's event in the page. You have to add the handler in ItemCreated-event of your inner repeater.
Here is a working example(VB.Net):
Main-Page codebehind:
Public Class RepeaterTest
Inherits System.Web.UI.Page
Sub Page_Load(ByVal Sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim comps As New List(Of Company)
comps.Add(New Company("Microsoft"))
comps.Add(New Company("Intel"))
comps.Add(New Company("Dell"))
Repeater1.DataSource = comps
Repeater1.DataBind()
End If
End Sub
Protected Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)
Select Case e.Item.ItemType
Case ListItemType.Item, ListItemType.AlternatingItem
Dim company As Company = DirectCast(e.Item.DataItem, Company)
Dim repeater2 As Repeater = DirectCast(e.Item.FindControl("Repeater2"), Repeater)
Dim deps As New List(Of Department)
deps.Add(New Department("purchasing", company))
deps.Add(New Department("management", company))
deps.Add(New Department("marketing", company))
deps.Add(New Department("logistics ", company))
repeater2.DataSource = deps
repeater2.DataBind()
End Select
End Sub
Protected Sub Repeater2_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)
Select e.Item.ItemType
Case ListItemType.Item, ListItemType.AlternatingItem
Dim uc_department As UC_Department = DirectCast(e.Item.FindControl("UC_Department1"), UC_Department)
'*** Here is all the "magic" ***'
AddHandler uc_department.NameChanged, AddressOf DepartmentSaved
End Select
End Sub
Protected Sub Repeater2_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)
Select Case e.Item.ItemType
Case ListItemType.Item, ListItemType.AlternatingItem
Dim department As Department = DirectCast(e.Item.DataItem, Department)
Dim uc_department As UC_Department = DirectCast(e.Item.FindControl("UC_Department1"), UC_Department)
uc_department.Department = department
End Select
End Sub
Private Sub DepartmentSaved(ByVal uc_Department As UC_Department)
' do something f.e. save to database '
End Sub
End Class
<Serializable()>
Public Class Company
Public Sub New(ByVal name As String)
Me.Name = name
End Sub
Public Property Name As String
Public Overrides Function ToString() As String
Return Me.Name
End Function
End Class
<Serializable()>
Public Class Department
Public Sub New(ByVal name As String, ByVal company As Company)
Me.Name = name
Me.Company = company
End Sub
Public Property Name As String
Public Property Company As Company
Public Overrides Function ToString() As String
Return Me.Name
End Function
End Class
aspx:
<asp:Repeater id="Repeater1" OnItemDataBound="Repeater1_ItemDataBound" runat="server">
<HeaderTemplate>
<table border="1">
<tr>
<td><b>Company</b></td>
<td><b>Departments</b></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<%# DataBinder.Eval(Container.DataItem, "Name")%>
</td>
<td>
<asp:Repeater ID="Repeater2" OnItemCreated="Repeater2_ItemCreated" OnItemDataBound="Repeater2_ItemDataBound" runat="server">
<HeaderTemplate>
<table border="1">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<uc1:UC_Department ID="UC_Department1" runat="server" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
The usercontrol's codebehind:
Public Class UC_Department
Inherits System.Web.UI.UserControl
Public Event NameChanged(ByVal ucDepartment As UC_Department)
Public Property Department As Department
Get
If ViewState("Company") Is Nothing Then Return Nothing
Return New Department(Me.TxtName.Text, DirectCast(ViewState("Company"), Company))
End Get
Set(ByVal value As Department)
Me.TxtName.Text = value.Name
ViewState("Company") = value.Company
End Set
End Property
Private Sub BtnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnSave.Click
RaiseEvent NameChanged(Me)
End Sub
End Class
and its ascx:
<%# Control Language="vb" AutoEventWireup="false" CodeBehind="UC_Department.ascx.vb" Inherits="DemoProject.UC_Department" %>
<asp:TextBox ID="TxtName" runat="server"></asp:TextBox>
<asp:Button ID="BtnSave" runat="server" Text="Save" />

Related

Dynamically generated Linkbutton does not fire Onclick event VB.Net

I have followed some of the instructions to create a new LinkButton at runtime with an event trigger and add an event handler for the LinkButton generated. I have no idea why the new LinkButton does not trigger the event added to it. Anyone please guide/correct me.
This is what I have right now.
ASPX:
<form id="myForm" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table class="mel-table" style="text-align: center" runat="server" id="mytab1">
<tbody>
<tr>
<td>Case Number :</td>
<td>
<asp:TextBox ID="caseNumber" runat="server"></asp:TextBox>
</td>
</tr>
</tbody>
</table>
<asp:Button OnClick="btnOK1_Click" ID="btnOK1" runat="server" Text="Save" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
ASPX.VB:
Protected Overloads Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Session("tablecontent") IsNot Nothing Then
mytab1 = CType(Session("tablecontent"), HtmlTable)
End If
End Sub
Public Function checking() As Boolean
Dim caseNo As Double
Try
caseNo = Convert.ToDouble((caseNumber.Text).Trim())
Catch ex As Exception
caseNo = 0
End Try
Dim r As New HtmlTableRow
Dim c0 As New HtmlTableCell
r.Cells.Add(c0)
Dim but As New LinkButton
but.ID = caseNo
but.Text = caseNo.ToString()
AddHandler but.Click, AddressOf LinkButton1_Click
c0.Controls.Add(but)
mytab1.Rows.Add(r)
Session("tablecontent") = mytab1
Return True
End Function
Protected Sub LinkButton1_Click(sender As Object, e As EventArgs)
'My Code here
End Sub
Protected Sub btnOK1_Click(sender As Object, e As EventArgs)
If (checking()) Then
ScriptManager.RegisterStartupScript(Page, Page.GetType, "Alert", "<script type='text/javascript'>alert('Success');</script>", False)
End If
End Sub
When you click on the "Save" button, save the data in either local storage or database and try to load the page again to fill the page with the content from the storage. In this case, you can have the content on the page and so, you can utilize the events also.
Whenever you create dynamic control you have to reload it on postback. I am using method call ReloadRows() for reloading added case which i am saving in ViewState:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional" >
<ContentTemplate>
<asp:Table class="mel-table" style="text-align: center" runat="server" id="mytab1">
<asp:TableRow>
<asp:TableCell>Case Number :</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="caseNumber" runat="server"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<asp:Button OnClick="btnOK1_Click" ID="btnOK1" runat="server" Text="Save" />
</ContentTemplate>
</asp:UpdatePanel>
--------------------------------------------------------------------------------------------------------
Public Partial Class _Default
Inherits System.Web.UI.Page
Private listCaseNo As List(Of Double) = Nothing
Protected Sub Page_Init(sender As Object, e As EventArgs)
End Sub
Protected Sub Page_Load(sender As Object, e As EventArgs)
If ViewState("ListCases") IsNot Nothing Then
listCaseNo = DirectCast(ViewState("ListCases"), List(Of Double))
Else
listCaseNo = New List(Of Double)()
End If
ReloadRows()
End Sub
Public Function checking() As Boolean
Dim caseNo As Double = 0
Try
caseNo = Convert.ToDouble((caseNumber.Text).Trim())
Catch ex As Exception
caseNo = 0
End Try
Dim r As New TableRow()
Dim c0 As New TableCell()
r.Cells.Add(c0)
Dim but As New LinkButton()
but.ID = Convert.ToString(caseNo)
but.Text = caseNo.ToString()
AddHandler but.Click, AddressOf LinkButton1_Click
c0.Controls.Add(but)
mytab1.Rows.Add(r)
listCaseNo.Add(caseNo)
ViewState("ListCases") = listCaseNo
Return True
End Function
Private Sub ReloadRows()
For Each objCase As var In listCaseNo
Dim r As New TableRow()
Dim c0 As New TableCell()
r.Cells.Add(c0)
Dim but As New LinkButton()
but.ID = Convert.ToString(objCase)
but.Text = objCase.ToString()
AddHandler but.Click, AddressOf LinkButton1_Click
c0.Controls.Add(but)
mytab1.Rows.Add(r)
Next
End Sub
Protected Sub LinkButton1_Click(sender As Object, e As EventArgs)
'My Code here
End Sub
Protected Sub btnOK1_Click(sender As Object, e As EventArgs)
If (checking()) Then
End If
End Sub
End Class

getting image src on click on image in data list

I have datalist containing images.
I have bounded these images to datalist by taking image names from database.
I just want to get src [Path of image] which user clicks on datalist.
My datalist is as following:
<asp:DataList ID="dlImages" runat="server" RepeatColumns="4">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" Height="200px" Width="200px" runat="server" />
</ItemTemplate>
</asp:DataList>
and i have bounded it as follows:
Protected Sub dlImages_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles dlImages.ItemDataBound
If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.EditItem Then
CType(e.Item.FindControl("ImageButton1"), ImageButton).ImageUrl = "~/ScreenMasterImages/" & e.Item.DataItem("PageName") & ".jpg"
End If
End Sub
Please help me to get src of particular image which user clicks on datasource.
I'd go for this:
Protected Sub ImageButton1_Click(sender As Object, e As ImageClickEventArgs)
Dim btn As ImageButton = sender
Dim selImage As String = btn.ImageUrl.ToString
MsgBox(btn.ImageUrl.ToString)
'Shorter:
Dim selImage As String = sender.ImageUrl.ToString
End Sub
Complete Code for testing:
Public Class WebForm1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim ditems As New List(Of di)
For i As Integer = 0 To 10
Dim dii As New di
dii.d_Name = "x" & i
ditems.Add(dii)
Next
dlImages.DataSource = ditems
dlImages.DataBind()
End If
End Sub
Protected Sub dlImages_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles dlImages.ItemDataBound
If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.EditItem Then
CType(e.Item.FindControl("ImageButton1"), ImageButton).ImageUrl = "~/ScreenMasterImages/" & DirectCast(e.Item.DataItem, di).d_Name & ".jpg"
End If
End Sub
Protected Sub ImageButton1_Click(sender As Object, e As ImageClickEventArgs)
Dim btn As ImageButton = sender
Dim selImage As String = btn.ImageUrl.ToString
MsgBox(btn.ImageUrl.ToString)
End Sub
End Class
Public Class di
Public Property d_Name() As String
Get
Return m_d_Name
End Get
Set(value As String)
m_d_Name = value
End Set
End Property
Private m_d_Name As String
End Class
And the asp:
<asp:DataList ID="dlImages" runat="server" DataKeyField="d_Name" DataMember="d_Name" RepeatColumns="4">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" OnClick="ImageButton1_Click" Height="200px" Width="200px" runat="server" />
</ItemTemplate>
</asp:DataList>

SelectedIndexChange event won't get fired,ASP.NET DropDownList

I have a Windows form with 1 DataGrid which has a Dropdownlist in one of its columns.
I also have another dropDownlist outside of this DataGrid.
Both of these dropdowns are bound to same dataset and both get populated with same items.
Both of DropDowns have their Autopostbacks set to true.
Problem is only for the dropdownlist Outside of Datagrid SelectedIndexChange Event gets fired:
(I have seen multiple similar questions on SO but none of suggestions works for me. So I really appreciate if you can help me here.
)
Protected Sub ABCD(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
For both Dropdownlists: AutoPostBack="True"
Here is Vb code:
Imports System.Data.OleDb
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents dg As New System.Web.UI.WebControls.DataGrid
Private cnDB As New OleDbConnection
Private ds As New DataSet
Private daDB As New OleDbDataAdapter
Protected allNames As New DataSet
Protected MyDataSet As DataSet
Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
Protected WithEvents DropDownList2 As System.Web.UI.WebControls.DropDownList
Protected WithEvents ddlName As New System.Web.UI.WebControls.DropDownList
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MyDataSet = NameBudget()
GridDataLoad()
End Sub
Protected Sub Grid_EditCommand(ByVal source As Object, ByVal e As DataGridCommandEventArgs)
dg.EditItemIndex = e.Item.ItemIndex
dg.DataSource = ds
dg.DataBind()
End Sub
Protected Sub Grid_CancelCommand(ByVal source As Object, ByVal e As DataGridCommandEventArgs)
dg.DataSource = ds.Tables(0).DefaultView
dg.EditItemIndex = -1
dg.DataSource = ds
dg.DataBind()
End Sub
Protected Sub Grid_UpdateCommand(ByVal source As Object, ByVal e As DataGridCommandEventArgs)
End Sub
Private Function GridDataLoad()
ddlName.DataSource = MyDataSet
Dim i As Object = MyDataSet.Tables(0)
ddlName.DataBind()
DropDownList1.DataSource = MyDataSet
DropDownList1.DataBind()
Dim strCon As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\AccessTestDataBases\TestDB.mdb; "
Dim cnDB As New OleDbConnection(strCon)
cnDB.Open()
daDB = New OleDbDataAdapter("Select * from [Persons]", cnDB)
daDB.Fill(ds, "tbl1")
Dim j As Object = ds.Tables(0)
dg.DataSource = ds
dg.DataBind()
cnDB.Close()
Dim ii As Object = ds.Tables(0)
End Function
Protected Function NameEditable(ByVal n As String) As Boolean
Return True
End Function
Protected Function NameBudget() As DataSet
Dim strCon As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\AccessTestDataBases\TestDB.mdb; "
Dim cnDB As New OleDbConnection(strCon)
cnDB.Open()
daDB = New OleDbDataAdapter("Select ID,Name from [Persons]", cnDB)
Dim ds As New DataSet
daDB.Fill(ds, "tbl1")
cnDB.Close()
Return ds
End Function
Sub SetDefaultListItem(ByVal sender As Object, ByVal e As System.EventArgs)
'*************************************************************************
'* Use this sub to set the Default List for DropDown Listboxes *
'*************************************************************************
Try
If Len(sender.DefaultValue) > 0 Then
If sender.Items.FindByValue(sender.DefaultValue).ToString.Length > 0 Then
sender.Items.FindByValue(sender.DefaultValue).Selected = True
End If
End If
Catch ex As System.Exception
'Throw New System.Exception(ex.ToString())
End Try
End Sub
Protected Sub ABCD(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
End Class
Here is the HTML for datagrid and Dropdownlists:
<Columns>
<ASP:ButtonColumn Text="Delete" CommandName="Delete"></ASP:ButtonColumn>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel"
EditText="Edit"></asp:EditCommandColumn>
<ASP:TemplateColumn HeaderText="Name" SortExpression="FY" HeaderStyle-HorizontalAlign="center" HeaderStyle-Wrap="True">
<ItemStyle Wrap="false" HorizontalAlign="left" />
<ItemTemplate>
<ASP:Label ID="Name" Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>' runat="server"/>
</ItemTemplate>
<EditItemTemplate>
<ASP:DropDownList id="DropDownlist2" datasource="<%# MyDataSet %>" DataTextField= "Name" DataValueField="ID" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ABCD">
</ASP:DropDownList>
</EditItemTemplate>
</ASP:TemplateColumn>
</Columns>
<asp:DropDownList id="DropDownList1"
datasource="<%# MyDataSet %>" DataTextField= "Name"
DataValueField="ID" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="ABCD">
</asp:DropDownList>

ObjectDataSource UpdateMethod passing updated values

I've got a gridview connected to an objectdatasource which is bound to some custom objects in my code (code is below). The problem I'm having is that the value passed into my update method is the old value, not the new value. Thoughts?
Imports System.Configuration
Imports System.Web.Configuration
Imports System.Security.Cryptography
Imports System.Collections.Generic
Partial Public Class ManageUsersControl
Inherits System.Web.UI.UserControl
Dim auth As AuthenticationSection
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Users.DataBind()
End Sub
End Class
Public Class Users
Private sName As String
Private sPassword As String
Public Sub New()
End Sub
Public Sub New(ByVal nm As String, ByVal pass As String)
Name = nm
Password = pass
End Sub
Public Property Name() As String
Get
Return sName
End Get
Set(ByVal value As String)
sName = value
End Set
End Property
Public Property Password() As String
Get
Return sPassword
End Get
Set(ByVal value As String)
sPassword = value
End Set
End Property
End Class
Public Class UserData
Dim auth As AuthenticationSection
Shared userTable As List(Of Users)
Public Sub New()
auth = CType(WebConfigurationManager.GetSection("system.web/authentication"), AuthenticationSection)
End Sub
Public Function CreateData() As List(Of Users)
Dim dt As New List(Of Users)
For Each user As FormsAuthenticationUser In auth.Forms.Credentials.Users
dt.Add(New Users(user.Name, user.Password))
Next
userTable = dt
Return userTable
End Function
Public Function SelectMethod() As List(Of Users)
If userTable Is Nothing Then
Return CreateData()
Else
Return userTable
End If
End Function
Public Function UpdateMethod(ByVal userInfo As Users) As Integer
Dim user As FormsAuthenticationUser = auth.Forms.Credentials.Users(userInfo.Name)
Dim pass As String
Dim sha As New SHA1CryptoServiceProvider()
Dim enc As New System.Text.ASCIIEncoding()
pass = enc.GetString(sha.ComputeHash(enc.GetBytes(userInfo.Password)))
userTable.Add(New Users(userInfo.Name, pass))
user.Password = pass
Return 1
End Function
End Class
and the markup:
<%# Control Language="vb" AutoEventWireup="false" CodeBehind="ManageUsers.ascx.vb" Inherits="mystuff.ManageUsersControl" %>
<asp:GridView ID="Users" runat="server" AutoGenerateColumns="False"
AutoGenerateEditButton="True" AutoGenerateDeleteButton="True"
DataSourceID="UsersData">
<Columns>
<asp:BoundField DataField="Name" HeaderText="User Name" />
<asp:TemplateField HeaderText="Password" >
<InsertItemTemplate>
<asp:TextBox runat="server" ID="InsertPassword" Text='<%# Bind("Password") %>' />
</InsertItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="EditPassword" Text='<%# Bind("Password") %>' />
</EditItemTemplate>
<ItemTemplate>
<asp:Label runat="server">*****</asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="UsersData"
DataObjectTypeName="mystuff.Users"
UpdateMethod="UpdateMethod"
SelectMethod="SelectMethod"
TypeName="mystuff.UserData"
runat="server"
OldValuesParameterFormatString="original_{0}"></asp:ObjectDataSource>
Just found the solution.
Partial Public Class ManageUsersControl
Inherits System.Web.UI.UserControl
Dim auth As AuthenticationSection
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then Users.DataBind()
End Sub
End Class
Also, discovered that you can't edit the users during execution of the application.

request.querystring

how can i use request.querystring in asp.net.i have a linkbutton and this is in a repeater control.i want to play video for the corresponding link _click.i want to pass a fileID of the corresponding link to a function,how can i do this ?
<asp:Repeater ID="Repeater2" runat="server">
<ItemTemplate>
<asp:LinkButton runat="server" ID="LnkBtn"
OnClick="ButtonShowVideo_Click"><%#Eval("FileName")%>
</asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
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 fileID**)
Repeater1.DataBind()
End Sub
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
This won't help you:
<asp:Repeater ID="Repeater2" runat="server">
<ItemTemplate>
<asp:LinkButton runat="server" ID="LnkBtn"
OnClick="ButtonShowVideo_Click"><%#Eval("FileName")%>
</asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
as it will not put FileName into query stirng. Rather use this method:
<asp:Repeater ID="Repeater2" runat="server">
<ItemTemplate>
<asp:LinkButton runat="server" ID="LnkBtn"
CommandArgument='<%#Eval("FileName")%>'
OnClick="ButtonShowVideo_Click"><%#Eval("FileName")%>
</asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
In code behind:
Protected Sub ButtonShowVideo_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ButtonShowVideo.Click
Dim btn as LinkButton = sender as LinkButton
if(btn is not null) then
if(NOT string.IsNullOrEmpty(btn.CommandArgument)) then
dim vid as integer = Convert.ToInt32(btn.CommandArgument)
Repeater1.DataSource = GetSpecificVideo(vid)
Repeater1.DataBind()
end if
end if
End Sub
If you plan to use query string, the button click can do either of the following:
Hyperlinks to a page with the designated quertstring to identify the action/entity etc
Do a server-side redirect to the page as describe in item 1 above
So where is your issue that you find challenging?

Resources