Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Why the row value is nothing?

Posted on 2008-10-01
4
Medium Priority
?
273 Views
Last Modified: 2012-05-05
Hi, I'm trying to retrieve the repeater's row at databound time but the row returned nothing:
       Dim row As DataRowView = TryCast(e.Item.DataItem, DataRowView)

Below is the entire code:
Private Sub rptList_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptList.ItemDataBound
        Dim imgIcon As Image = CType(e.Item.FindControl("imgIcon"), Image)
        Dim row As DataRowView = TryCast(e.Item.DataItem, DataRowView)
 
End Sub

Open in new window

0
Comment
Question by:Abdu_Allah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 23

Expert Comment

by:Snarf0001
ID: 22613474
Can you show the code for your databinding?  Are you sure it's a DataRowView being returned?
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 22613515
Here is the code of binding:

Dim directory2 As DirectoryInfo = New DirectoryInfo(strPath)
Try
rptList.DataSource = directory2.GetFiles()
rptList.DataBind()
Catch ex As System.UnauthorizedAccessException
Response.Write(" Access Denied.")
Catch ex As System.IO.IOException
Response.Write(" Unknown error: " + ex.Message)
Finally
directory2 = Nothing
End Try
0
 
LVL 23

Accepted Solution

by:
Snarf0001 earned 2000 total points
ID: 22613556
Okay, thats exactly the problem.
You'll only get a DataRowView if you're binding with a datatable / dataview.

since you're binding with DirectoryInfo.GetFiles(), which returns an array of FileInfo objects, that's what you need to cast to.
Private Sub rptList_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptList.ItemDataBound
        Dim imgIcon As Image = CType(e.Item.FindControl("imgIcon"), Image)
        Dim info As FileInfo = TryCast(e.Item.DataItem, FileInfo)
 
End Sub

Open in new window

0
 
LVL 20

Expert Comment

by:informaniac
ID: 22613602
TRY THIS

       
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then

Dim imgIcon As Image = CType(e.Item.FindControl("imgIcon"), Image)
        Dim row As DataRowView = TryCast(e.Item.DataItem, DataRowView)

End If
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question