Repeater Question

Discussion in 'ASP .Net' started by Mick Walker, Aug 3, 2007.

  1. Mick Walker

    Mick Walker Guest

    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
     
    Mick Walker, Aug 3, 2007
    #1
    1. Advertising

  2. This should do:

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

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


    "Mick Walker" <> wrote in message
    news:...
    > 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, Aug 3, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    861
  2. Replies:
    0
    Views:
    2,885
  3. Replies:
    1
    Views:
    7,031
    Karl Seguin
    Aug 10, 2005
  4. uncensored
    Replies:
    0
    Views:
    818
    uncensored
    Oct 25, 2006
  5. Microsoft

    Repeater inside a Repeater

    Microsoft, Aug 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    209
    Microsoft
    Aug 21, 2006
Loading...

Share This Page