Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

Repeater Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mick Walker - 03 Aug 2007 13:40 GMT
Hi All,

I am using a repeater to display messages to users within my website. I
get the messages by binding a SqlDataSource to the repeater, and
accessing them directly from the database.
However, in my messages database, I only store the GUID of the user whom
sent the message.

Currently I bind the data to the repeater as so:
<ItemTemplate>
                        <tr>
                            <td align="left" valign="top"><asp:label
ID="lblDate" Text='<%#Eval("DateSent") %>' runat="server"></asp:label></td>
                            <td align="left" valign="top"><asp:Label
ID="lblfrom" Text='<%#Eval("FromID") %>' runat="server"></asp:Label></td>
                            <td align="left" valign="top"><asp:label
ID="lblSubject" Text='<%#Eval("Subject") %>'
runat="server"></asp:label><asp:TextBox ID="txtMsgID" runat="server"
Visible="false" Text='<%#Eval("ID") %>' /></td>
                            <td align="left" valign="top">
                                <asp:CheckBox ID="chkAction"
runat="server" />
                            </td>
                        </tr>
                    </ItemTemplate>

This obviously only gives me the user ID of the person whom sent the
message.

Is there any way, within my codebehind I could create a function such as:

Public Function GetUserName(byval UserID as Guid) as string
    look up the users username in the access table, by their GUID
   
    Return the Username
End Function

And then call this function from my markup(within the repeater
itemtemplate)then bind the return value to the repeater?

Kind Regards
Mick Walker
Eliyahu Goldin - 03 Aug 2007 14:02 GMT
This should do:

<asp:Label > ID="lblfrom" Text='<%# GetUserName(Eval("FromID")) %>'
runat="server"></asp:Label>

Signature

Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin

> Hi All,
>
[quoted text clipped - 38 lines]
> Kind Regards
> Mick Walker

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.