I have the following code in child window which is working but what I want to do is instead of using response.write I want to use label control or to display all the filename like this:
music.pdf, inventory.doc
My Ultimate goal is to pass the values in string (e.g.: "music.pdf, inventory.pdf" ) to the parent window.
How do I do it?
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
Try
'' Get the HttpFileCollection
Dim hfc As HttpFileCollection = Request.Files
For i As Integer = 0 To hfc.Count - 1
Dim hpf As HttpPostedFile = hfc(i)
If hpf.ContentLength > 0 Then
hpf.SaveAs(Server.MapPath("/ServerName/DirectoryName") & "\"" & System.IO.Path.GetFileName(hpf.FileName))
Response.Write("<b>File: </b>" & hpf.FileName & " <b>Size:</b> " & hpf.ContentLength & " <b>Type:</b> " & hpf.ContentType & " Uploaded Successfully! <br/>")
Else
Response.Write("Please select a file to upload.")
End If
Next i
Catch ex As Exception
End Try
End Sub
This is not the way I would do it but you asked for your code to work with a Label.
ASPX:
<asp:Label id="lblUploadMsg" runat="server" visible="false"></asp:Label>
Code:
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
Try
'' Get the HttpFileCollection
Dim hfc As HttpFileCollection = Request.Files
lblUploadMsg.Text = String.empty
For i As Integer = 0 To hfc.Count - 1
Dim hpf As HttpPostedFile = hfc(i)
If hpf.ContentLength > 0 Then
hpf.SaveAs(Server.MapPath("/ServerName/DirectoryName") & "\"" & System.IO.Path.GetFileName(hpf.FileName))
lblUploadMsg.Visible = True;
lblUploadMsg.Text +="<b>File: </b>" & hpf.FileName & " <b>Size:</b> " & hpf.ContentLength & " <b>Type:</b> " & hpf.ContentType & " Uploaded Successfully! <br/>"
Else
lblUploadMsg.Text="Please select a file to upload."
End If
Next i
''HTML Encode lblUploadingMsg.Text after
Catch ex As Exception
End Try
End Sub
Consider using a <asp:BulletedList>, which is an ASP.NET server control for an unordered list <ul>.
ASPX:
<asp:BulletedList
id="uploadedFiles" runat="server"></asp:BulletedList>
Instead of Response.Write() each file, simply:
Dim displayText as String = string.Format("File: {0} Size: {1} Type: {2} Uploaded Successfully", _
hpf.FileName ,hpf.ContentLength ,hpf.ContentType)
uploadedFiles.Items.Add(New ListItem(displayText, hpf.FileName ))
Add a label control onto the form/control and then instead of using Response.Write, why not use a string builder and append all of the output to that in the loop. Once you have processed all of the files set the Label control's Text property of the string builder ToString method.
Hope this helps
You can use one of the String.Join() overloads.
Use a string builder to join strings. Strings in .NET are immutable, so Join and any other operators are memory intensive
Comment (not on the question, but I noticed it in your code) Use Path.Combine and any other Path functions. Amazingly easy to forget that they exist and have saved me millions of headaches.
Move your Response.Write outside of the loop over i.
Inside of i loop, keep track using a List<String>. Then, after the loop, use the Response.Write, to write a String.Join over the List.ToArray with a comma.
Using a Label control won't honour your <b> tags - what you're looking for here is to use the Literal control. Try something like this:
In your markup:
<asp:literal runat="server" id="UploadedFileInfoLiteral" />
In your code-behind:
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
Try
'' Get the HttpFileCollection
Dim hfc As HttpFileCollection = Request.Files
Dim FileInfoStringBuilder As System.Text.StringBuilder = New System.Text.StringBuilder
Dim hpf As HttpPostedFile
For i As Integer = 0 To hfc.Count - 1
hpf = hfc(i)
If hpf.ContentLength > 0 Then
hpf.SaveAs(Server.MapPath("/ServerName/DirectoryName") & "\"" & System.IO.Path.GetFileName(hpf.FileName))
FileInfoStringBuilder.Append("<strong>File: </strong>" & hpf.FileName & " <strong>Size:</strong> " & hpf.ContentLength & " <strong>Type:</strong> " & hpf.ContentType & " Uploaded Successfully! <br/>")
Else
FileInfoStringBuilder.Append("Please select a file to upload.")
End If
Next
UploadedFileInfoLiteral.Text = FileInfoStringBuilder.ToString()
Catch ex As Exception
End Try
End Sub
Related
Other than Request.Form("example") which use the name of the textbox. I want to know if there is any other way to get the value rather than using the Request.Form. I hope you guys understand what I mean and I hope this is not a dumb question. As I'm having problem using the name to get the value of what the textbox consist.
So I thought of using the id to get the value do tell me if that could work.And I would also like to know how it works.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
For Each row As DataRow In cardDT.Rows
Literal1.Text += "<tr>"
Literal1.Text += "<td><input type='text' id='test" & i & "' name='test" & i & "' value='" & row("Date") & "' maxlength='20'></td>"
Literal1.Text += "<td><input id='Checkbox1' type='checkbox' name='chk" & i & "' /></td>"
Literal1.Text += "</tr>"
i += 1
Next
Literal1.Text += " </table>"
End Sub
This is the button, for now is just check the value stored in request.form but when I click on this button I receive an error when I used the name:
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
Dim i = 0
For Each row As DataRow In EmployeeDt.Rows
Dim t = Request.Form("test" & i)
If Request.Form("check" & i) <> "" Then
MsgBox("check" & i & " " & t)
End If
i += 1
Next
End Sub
There are two ways. You can choose which one suits your needs:
Change your html input control to asp:TextBox control. This will still render in the browser as html input anyways. So it shouldn't make a difference, but you would be able to access it in your code-behind. You can then get its value by ControlId.Text.
Just add the RunAt="Server" attribute on your html input (textbox) control, and you can access it in the code-behind as any other server side control. You can then probably get it value by ControlId.Value.
I got a toolbar with different actions the user can start. In the user interface it looks like:
If I press on the "Ok" button the value will not known at the backend. My code structure is the following:
Configuration of an action
<Action Id="MyAction" Name="Action with Form">
<Form>
<asp:TextBox xmlns:asp="System.Web.UI.WebControls" ID="txtValue" runat="server" />
</Form>
</Action>
ASPX-File
<asp:Content ContentPlaceHolderID="cphToolbar" Runat="Server">
<asp:PlaceHolder ID="plhToolbar" runat="server" />
</asp:Content>
VB-File to the ASPX-File
Partial Class Form
Inherits UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.plhToolbar.Controls.Add(Me.CreateActionToolbar(<XML configuration element for the toolbar>))
End Sub
End Class
Page base class
Namespace UI
Public MustInherit Class Page
Inherits System.Web.UI.Page
Protected Overridable Function CreateActionToolbar(source As XmlElement) As Interfaces.IActions
Dim oAction As Interfaces.IActions = Me.LoadControl("~/Controls/Toolbar/Actions.ascx")
For Each element As XmlElement In source.SelectNodes("node()").OfType(Of XmlElement)()
Dim NewItem As New Controls.ActionItem
'set settings for the toolbar element
'add fields to form
For Each Item As XmlNode In element.SelectNodes("Form/node()", oNamespaceManager)
If (TypeOf Item Is XmlElement) Then
If (NewItem.Fields Is Nothing) Then NewItem.Fields = New List(Of XmlElement)
NewItem.Fields.Add(Item)
End If
Next
oAction.Items.Add(NewItem)
Next
Return oAction
End Function
End Class
End Namespace
Action user control
Partial Class Actions
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
For Each Item As ActionItem In Me.Items
'set settings for action
If (Not (Item.Fields Is Nothing)) Then
Dim oPanel As New Panel
oPanel.ID = "dlgActionPanel" & Me.dlgAction.Controls.Count
Me.dlgAction.Controls.Add(oPanel)
Dim oFields As New Panel
oFields.ID = oPanel.ID & "_Controls"
For Each Field As XmlElement In Item.Fields
Dim oControl As System.Web.UI.Control = Nothing
Try
oControl = Me.ParseControl(Field.OuterXml)
Catch ex As Exception
oControl = New LiteralControl("<font style=""color:red;"">" & ex.Message & "</font>")
End Try
oFields.Controls.Add(oControl)
Next
Dim pnlResult As New Panel
Dim btnOk As New Button
btnOk.ID = "btnOk_" & oPanel.ID
AddHandler btnOk.Click, AddressOf Ok_Click
btnOk.Attributes.Add("onclick", "ShowWaitDialog();")
btnOk.Attributes.Add("ItemId", NewAnchor.Attributes("ItemId"))
btnOk.UseSubmitBehavior = False
btnOk.Text = Me.AcceptDialogText
pnlResult.Controls.Add(btnOk)
Dim btnCancel As New Button
btnCancel.Attributes.Add("onclick", "ShowWaitDialog();$('#" & oPanel.ClientID & "').dialog('close');CloseWaitDialog();return false;")
btnCancel.Text = Me.CancelDialogText
pnlResult.Controls.Add(btnCancel)
oPanel.Controls.Add(oFields)
oPanel.Controls.Add(pnlResult)
Dim strMessageControlId As String = oPanel.ClientID
strClientScript &= "$(""#" & strMessageControlId & """).dialog({" & NewLine
strClientScript &= " bgiframe:true, " & NewLine
strClientScript &= " autoOpen:false, " & NewLine
strClientScript &= " modal:true, " & NewLine
strClientScript &= " closeOnEscape:false, " & NewLine
strClientScript &= " width:600, " & NewLine
strClientScript &= " height:450, " & NewLine
strClientScript &= " minWidth:450, " & NewLine
strClientScript &= " minHeight:300, " & NewLine
If (Not (Item.Description Is Nothing)) Then strClientScript &= " title:'" & Item.Description & "', " & NewLine
strClientScript &= " open: function(event, ui) { $("".ui-dialog-titlebar-close"").hide(); } " & NewLine
strClientScript &= "});" & NewLine
If (String.IsNullOrEmpty(NewAnchor.Attributes("onclick"))) Then NewAnchor.Attributes.Add("onclick", String.Empty)
NewAnchor.Attributes("onclick") &= "$('#" & oPanel.ClientID & "').dialog('open');"
End If
Next
End Sub
Private Sub Ok_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim oDialog As Panel = Nothing
If (Not (String.IsNullOrEmpty(sender.ID))) Then oDialog = Me.dlgAction.FindControl(sender.ID.Substring(sender.ID.IndexOf("_") + 1) & "_Controls")
Dim oAction As ActionItem = Items.Find(Function(item) item.ItemId = sender.Attributes("ItemId"))
If (Not (oDialog Is Nothing)) Then
For Each Field As XmlElement In oAction.Fields
Dim oControl As WebControl = Nothing
If (Not (Field.SelectSingleNode("#Id|#ID") Is Nothing)) Then oControl = oDialog.FindControl(Field.SelectSingleNode("#Id|#ID").Value)
If (Not (oControl Is Nothing)) Then
Dim oParameter As SqlClient.SqlParameter = oAction.Parameters.Find(Function(item) item.ParameterName = "#" & oControl.ID.Substring(3))
If (Not (oParameter Is Nothing)) Then
Select Case oControl.GetType.ToString
Case GetType(TextBox).ToString
'After postback the value is empty!!!
If (Not (String.IsNullOrEmpty(CType(oControl, TextBox).Text))) Then oParameter.Value = CType(oControl, TextBox).Text
'more controls
Case Else
End Select
End If
End If
Next
End If
End Sub
End Class
Where is the fault that the value of the TextBox is after PostBack empty and not set because of the View State?
Thanks for any response.
I could solve it. The problem was that the jQuery dialog was not PostBack save. The solution was
$("#dialog").dialog({
appendTo:'form:first'
});
I am using visual developer 2012 and have a simple form to upload the file to the server and then enter the name of the file into another table. For whatever reason it runs twice and enter the values twice in the second table:
Protected Sub BtnUploadImg_Click(sender As Object, e As EventArgs) Handles BtnUploadImg.Click
If IsPostBack Then
' Dim CurrentPath As String = Server.MapPath("C:\DSimages\")
If FileUpLoad1.HasFile = True Then
Try
FileUpLoad1.SaveAs("C:\DSimages\" & _
FileUpLoad1.FileName)
Label1.Text = "File name: " & _
FileUpLoad1.PostedFile.FileName & "<br>" & _
"File Size: " & _
FileUpLoad1.PostedFile.ContentLength & " kb<br>" & _
"Content type: " & _
FileUpLoad1.PostedFile.ContentType
ImageDataSource.InsertParameters("ImgName").DefaultValue = FileUpLoad1.PostedFile.FileName
Catch ex As Exception
Label1.Text = "ERROR: " & ex.Message.ToString()
End Try
Else
Label1.Text = "You have not specified a file."
End If
End If
ImageDataSource.Insert()
FileUpLoad1.PostedFile.InputStream.Dispose()
End Sub
Do you have the same code under the page load event? The postback will fire both events, so if you do it will run twice.
I have a treeview type structure of folders/links that's populated from a table. What I was attempting to do was procedural loop through my recordset and generate my html in page_init and then try and bind the controls. When I try to add the link buttons to the placeholders in html, it can never seem to find them.
I might be missing something fundamental here, all the examples i've seen bind a control thats already on the page, am I unable to generate the html myself in page_init?
example
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
content_div.Innerhtml = "<asp:PlaceHolder id=""test"" runat=""server"" ></asp:PlaceHolder>"
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim _linkb As New LinkButton
_linkb.ID = "lb_cat_" & cat.uID
_linkb.Attributes.Add("href", "javascript: sltoggle('cat_" & cat.uID & "');")
_linkb.Attributes.Add("Text", "Expand/Close")
_linkb.Attributes.Add("runat", "server")
Dim ph As PlaceHolder = DirectCast(TRIEDEVERYTHINGUNDERTHESUN.FindControl("test"), PlaceHolder)
ph.Controls.Add(_linkb)
End Sub
If someone could point me in the right direction it'd be much appreciated
Regards,
Pete
UPDATE - full code
Private Sub load_dynamic_file_view()
Dim _sb As New StringBuilder
Dim _sfc As New sf_file_category, _sff As New sf_file
_lsfc = _sfc.get_all_sf_file_category
_lsff = _sff.get_active_sf_files
Dim _list_root As List(Of sf_file_category) = _lsfc.FindAll(Function(p) p.parent_id = 0)
If Not _list_root Is Nothing Then
_sb.Append("<strong>File Downloads</strong><br />")
_sb.Append("<div class=""indent-me"" ><br />")
For Each cat As sf_file_category In _list_root
'header/Open Link
Dim _linkb As New LinkButton
_linkb.ID = "lb_cat_" & cat.uID
_linkb.Attributes.Add("href", "javascript: sltoggle('cat_" & cat.uID & "');")
_linkb.Attributes.Add("Text", "Expand/Close")
_linkb.Attributes.Add("runat", "server")
Dim ph As PlaceHolder = DirectCast(Me.Master.FindControl("lb_cat_" & cat.uID), PlaceHolder)
ph.Controls.Add(_linkb)
_sb.Append(HtmlDecode(cat.name) & " <Asp:PlaceHolder id=""lb_cat_" & cat.uID & """ runat=""server"" /><br />")
'_sb.Append("<div id=""cat_" & cat.uID & """ class=""toggle-hide"">")
'_sb.Append(add_child_folder(cat.uID, content))
'_sb.Append(show_files(cat.uID, content))
'_sb.Append("</div><div class=""clearfix"" />")
Next
_sb.Append("</div>")
_sb.Append("<br /><br />")
End If
content_div.InnerHtml = _sb.ToString
End Sub
Private Function add_child_folder(ByVal catid As Long, ByRef content As ContentPlaceHolder) As String
Dim _sb As New StringBuilder
Dim _cl As List(Of sf_file_category) = _lsfc.FindAll(Function(p) p.parent_id = catid)
If Not _cl Is Nothing Then
_sb.Append("<div class=""indent-me"" ><br />")
'For Each _c As sf_file_category In _cl.OrderBy(Function(p) p.view_order)
_cl.Sort(Function(c1 As sf_file_category, c2 As sf_file_category)
Return c1.view_order.CompareTo(c2.view_order)
End Function)
For Each cat As sf_file_category In _cl
Dim _linkb As New LinkButton
_linkb.ID = "lb_cat_" & cat.uID
_linkb.Attributes.Add("href", "javascript: sltoggle('cat_" & cat.uID & "');")
_linkb.Attributes.Add("Text", "Expand/Close")
_linkb.Attributes.Add("runat", "server")
Content.Controls.Add(_linkb)
_sb.Append(HtmlDecode(cat.name) & " <Asp:LinkButton id=""lb_cat_" & cat.uID & """ runat=""server"" Text=""Expand/Close"" href='javascript: sltoggle('cat_" & cat.uID & "');' /><br />")
'_sb.Append("<div id=""cat_" & cat.uID & """ class=""toggle-hide"">")
_sb.Append(add_child_folder(cat.uID, content))
_sb.Append(show_files(cat.uID, content))
'_sb.Append("</div><div class=""clearfix"" >")
Next
_sb.Append("</div><br />")
End If
Return _sb.ToString
End Function
Private Function show_files(ByVal catid As Long, ByRef content As ContentPlaceHolder) As String
Dim _sb As New StringBuilder
Dim _fl As List(Of sf_file) = _lsff.FindAll(Function(p) p.file_category = catid)
If Not _fl Is Nothing Then
_sb.Append("<div class=""indent-me"" ><br />")
For Each _f As sf_file In _fl
Dim _linkb As New LinkButton
_linkb.ID = "file_" & _f.uID
_linkb.Attributes.Add("onCommand", "download_file")
_linkb.Attributes.Add("CommandArgument", _f.uID.ToString)
_linkb.Attributes.Add("Text", _f.file_name)
_linkb.Attributes.Add("runat", "server")
AddHandler _linkb.Command, AddressOf download_file
content.Controls.Add(_linkb)
_sb.Append("<asp:LinkButton id=""file_" & _f.uID & """ runat=""server"" onCommand=""download_file"" commandArgument=""" & _f.uID & """ Text=""" & _f.file_name & """ /><br />")
Next
_sb.Append("</div><br />")
End If
Return _sb.ToString
End Function
What your full code shows is that your building a massive string of HTML. This is fine for some smaller situations, but your code is clearly getting quite big now, and I would suggest you change this approach.
I would recommend that you declare web control equivalents, such as:
new HtmlGenericControl("div") instead of <div></div>
OR
new HtmlAnchor() OR new LinkButton() instead of <a></a>
In the example of a tree structure the HTML may look like this:
<ul>
<li>
ROOT
<ul>
<li>
LEVEL 1
</li>
</ul>
</li>
</ul>
To generate this in code you would do something similar to:
'Menu Holder
Dim treeStruct As HtmlGenericControl("ul")
'Root
Dim branch As HtmlGenericControl("li")
Dim branchItem as HtmlAnchor("a")
'Level 1
Dim subLevel As HtmlGenericControl("ul")
Dim subBranch As HtmlGenericControl("li")
Dim subBranchItem as HtmlAnchor("a")
'Setup Level 1
subBranchItem.InnerText = "LEVEL 1"
subBranchItem.Href = "levelone"
subBranch.Controls.Add(subBranchItem)
subLevel.Controls.Add(subBranch)
'Setup Root
branchItem.InnerText = "ROOT"
branchItem.Href = "root.htm"
'Add Link To Root
branch.Controls.Add(branchItem)
'Add Sub Branch To Root
branch.Controls.Add(subLevel)
treeStruct.Controls.Add(branch)
Important The code above is just for examples sake, ideally you would separate the functionality into functions for branch creation and then loop through your elements with your for loop.
You will also notice that I have used an <UL> instead of <DIV> as I would consider a tree structure to be an un-ordered list. Plus, you will also get the styling benefit from this more ridged structure.
I hope this helps
You generate only HTML tags and do not generate ASP.Net tags, as they can't be parsed by browser.
I think your code should be like
content_div.Innerhtml = "<div id='test'></div>"
ASP:Placeholder control is just a place holder and it is not equal to div HTML tag.
For an example i gave div tag here.
asp.net controls added as text are not known to the page and thus no viewstate / object is stored for it, thus you can never find it using Findcontrol.
Use the object of the control and add it to the parent control's Control collection
e.g.
div.Controls.Add(new PlaceHolder() { ... });
Once you have added it before Render event , its state will be saved and accessable.
It looks like your trying to add a placeholder to the content_div, however, what you are doing is rendering the tag as HTML content.
I don't know exactly what type of control content_div is, but can't you try:
content_div.controls.add(new placeholder() { ID = "test" });
This would then allow you to find the control within the content_div control.
However, what would probably be a much more concise solution for you might be the following:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim _linkb As New LinkButton
_linkb.ID = "lb_cat_" & cat.uID
_linkb.Attributes.Add("href", "javascript: sltoggle('cat_" & cat.uID & "');")
_linkb.Attributes.Add("Text", "Expand/Close")
//you don't need this when using code behind
//_linkb.Attributes.Add("runat", "server")
//this will add your linkbutton to the content_div control
content_div.Controls.Add(_linkb)
End Sub
Give this ago and you should find it to be a useful way of dynamically building your page with asp controls.
I have following code in page load
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
GetDetails()
PopulateRepeater()
End If
End Sub
Sub PopulateRepeater()
Dim dt As DataTable = GetDetails()
Dim dtDoc As DataTable = objdoc.GetDocDetails(Session("RegID"))
If dtDoc.Rows.Count > 0 Then
Dim strUserName As String = dt.Rows(0)("Name")
Dim files As IList(Of FileInfo) = New List(Of FileInfo)()
Dim filters As String = "*.jpg;*.png;*.gif"
For Each filter As String In filters.Split(";"c)
Dim fit As FileInfo() = New DirectoryInfo(Me.Server.MapPath("../SiteImages/" & strUserName & "/" & Session("RegID") & "/")).GetFiles(filter)
For Each fi As FileInfo In fit
files.Add(fi)
Next
Next
strPath = Server.MapPath("../SiteImages/" & strUserName & "/" & Session("RegID") & "/")
Me.Repeater1.DataSource = files
Me.Repeater1.DataBind()
End If
End Sub
I have following code in itemdatabound
Dim ThViewr As Bright.WebControls.ThumbViewer = DirectCast(e.Item.FindControl("Th1"), Bright.WebControls.ThumbViewer)
Dim dtUser As DataTable = GetDetails()
Dim dtDoc As DataTable = objdoc.GetDocDetails(Session("RegID"))
Dim strUserName As String = dtUser.Rows(0)("Name")
If dtDoc.Rows.Count > 0 Then
For i As Integer = 0 To dtDoc.Rows.Count - 1
Dim ImagePath As String = "../SiteImages/" & strUserName & "/" & Session("RegID") & "/" + dtDoc.Rows(i)("ImageName")
ThViewr.ImageUrl = ImagePath
Next
End If
My aspx contains
<div style="clear:both;">
<asp:Repeater ID="Repeater1" runat="server" >
<ItemTemplate>
<span style="padding:2px 10px 2px 10px">
<bri:ThumbViewer Id="Th1" runat="server" Height="100px" Width="100px"/>
</span>
</ItemTemplate>
</asp:Repeater>
</div>
If the imagePath ="../SiteImages/Ram/PR/First.jpg" Means the folder PR aontains exactly 3 images namely First.jpg,Second.jpg and Third.jpg.
Now with above code three images are coming but Third.jpg is repeating 3 times.First.jpg and Second.jpg is not coming.Can anybody help to resolve this.
The ItemDataBound event is raised once for every object in the bound list, so it will be fired three times in your case; once for each file. You should not loop over your data table, but rather grab the current item from the event args.
Update: looking closer at the code I find it somewhat confusing. You bind a list of FileInfo objects to the repeater, but fetch data from a DataTable when the items are bound. I am guessing that you want to show the files found, and I think that the following code in ItemDataBound will do that for you:
Dim ThViewr As Bright.WebControls.ThumbViewer = DirectCast(e.Item.FindControl("Th1"), Bright.WebControls.ThumbViewer)
Dim dtUser As DataTable = GetDetails()
Dim strUserName As String = dtUser.Rows(0)("Name")
Dim ImagePath As String = "../SiteImages/" & strUserName & "/" & Session("RegID") & "/" + DirectCast(e.Item.DataItem, FileInfo).Name
ThViewr.ImageUrl = ImagePath