Add formatted text to JavaScript function call during ItemDataBound of a Repeater Control.

Discussion in 'ASP .Net Datagrid Control' started by Bryan, Oct 26, 2004.

  1. Bryan

    Bryan Guest

    Hello,

    I am taking values from a datatable and formatting them for use in a
    JavaScript Function Call.
    The end result is a mouse over tool tip.

    Here is what I am doing.

    I have tried to use a property but it uses the last set value of all.

    Private Sub drTasks_ItemDataBound(ByVal sender As Object,
    ByVal e As
    System.Web.UI.WebControls.RepeaterItemEventArgs)
    Handles
    drTasks.ItemDataBound
    If e.Item.ItemType = ListItemType.Item Then

    Dim ttTitle As String = IIf(Not IsDBNull(e.Item.DataItem("Title")),
    e.Item.DataItem("Title"), "")
    Dim ttDesc As String = IIf(Not
    IsDBNull(e.Item.DataItem("Description")), e.Item.DataItem("Description"),
    "")
    Dim ttDateStart As String = IIf(Not
    IsDBNull(e.Item.DataItem("DateStart")),
    CDate(e.Item.DataItem("DateStart")).ToShortDateString, "")
    Dim ttDateDue As String = IIf(Not
    IsDBNull(e.Item.DataItem("DateDue")),
    CDate(e.Item.DataItem("DateDue")).ToShortDateString, "")

    Dim ToolTip As New System.Text.StringBuilder

    ' First I build the text
    ToolTip.Append("Title: " & ttTitle & "<br /><br />")
    If ttDesc <> "" Then ToolTip.Append(ttDesc & "<br /><br />")
    ToolTip.Append("Start Date: " & ttDateStart & "<br />Due Date: " &
    ttDateDue)

    ' Once I have finished I push the value into the description.
    e.Item.DataItem("Description") = ToolTip

    End If
    End Sub

    On the HTML side I use the following in the <ItemTemplate> of the Repeater
    Control.
    ...<td.... onMouseover="ddrivetip('<%#DataBinder.Eval(Container,
    "DataItem.Description")%>','#284461', 300)">...

    Any Iteas?

    Thanks,
    Bryan
     
    Bryan, Oct 26, 2004
    #1
    1. Advertising

  2. try building the javascript embedded in the cell in the itemdatabound. Here
    is some sample code.
    e.Item.Cells[1].Attributes.Add("onmouseover","add your tooltip code here");





    --
    Regards,
    Alvin Bruney
    [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
    Got tidbits? Get it here... http://tinyurl.com/27cok
    "Bryan" <> wrote in message
    news:...
    > Hello,
    >
    > I am taking values from a datatable and formatting them for use in a
    > JavaScript Function Call.
    > The end result is a mouse over tool tip.
    >
    > Here is what I am doing.
    >
    > I have tried to use a property but it uses the last set value of all.
    >
    > Private Sub drTasks_ItemDataBound(ByVal sender As Object,
    > ByVal e As
    > System.Web.UI.WebControls.RepeaterItemEventArgs)
    > Handles
    > drTasks.ItemDataBound
    > If e.Item.ItemType = ListItemType.Item Then
    >
    > Dim ttTitle As String = IIf(Not IsDBNull(e.Item.DataItem("Title")),
    > e.Item.DataItem("Title"), "")
    > Dim ttDesc As String = IIf(Not
    > IsDBNull(e.Item.DataItem("Description")), e.Item.DataItem("Description"),
    > "")
    > Dim ttDateStart As String = IIf(Not
    > IsDBNull(e.Item.DataItem("DateStart")),
    > CDate(e.Item.DataItem("DateStart")).ToShortDateString, "")
    > Dim ttDateDue As String = IIf(Not
    > IsDBNull(e.Item.DataItem("DateDue")),
    > CDate(e.Item.DataItem("DateDue")).ToShortDateString, "")
    >
    > Dim ToolTip As New System.Text.StringBuilder
    >
    > ' First I build the text
    > ToolTip.Append("Title: " & ttTitle & "<br /><br />")
    > If ttDesc <> "" Then ToolTip.Append(ttDesc & "<br /><br />")
    > ToolTip.Append("Start Date: " & ttDateStart & "<br />Due Date: " &
    > ttDateDue)
    >
    > ' Once I have finished I push the value into the description.
    > e.Item.DataItem("Description") = ToolTip
    >
    > End If
    > End Sub
    >
    > On the HTML side I use the following in the <ItemTemplate> of the Repeater
    > Control.
    > ...<td.... onMouseover="ddrivetip('<%#DataBinder.Eval(Container,
    > "DataItem.Description")%>','#284461', 300)">...
    >
    > Any Iteas?
    >
    > Thanks,
    > Bryan
    >
     
    Alvin Bruney [MVP], Oct 26, 2004
    #2
    1. Advertising

  3. Bryan

    Bryan Guest

    Thanks for the tip.

    I know that what you mentioned works with the datagrid control but it
    doesn't work with the repeater control.
    I will keep trying .

    Thanks again,
    Bryan

    "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
    news:%...
    > try building the javascript embedded in the cell in the itemdatabound.
    > Here is some sample code.
    > e.Item.Cells[1].Attributes.Add("onmouseover","add your tooltip code
    > here");
    >
    >
    >
    >
    >
    > --
    > Regards,
    > Alvin Bruney
    > [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
    > Got tidbits? Get it here... http://tinyurl.com/27cok
    > "Bryan" <> wrote in message
    > news:...
    >> Hello,
    >>
    >> I am taking values from a datatable and formatting them for use in a
    >> JavaScript Function Call.
    >> The end result is a mouse over tool tip.
    >>
    >> Here is what I am doing.
    >>
    >> I have tried to use a property but it uses the last set value of all.
    >>
    >> Private Sub drTasks_ItemDataBound(ByVal sender As Object,
    >> ByVal e As
    >> System.Web.UI.WebControls.RepeaterItemEventArgs)
    >> Handles
    >> drTasks.ItemDataBound
    >> If e.Item.ItemType = ListItemType.Item Then
    >>
    >> Dim ttTitle As String = IIf(Not
    >> IsDBNull(e.Item.DataItem("Title")), e.Item.DataItem("Title"), "")
    >> Dim ttDesc As String = IIf(Not
    >> IsDBNull(e.Item.DataItem("Description")), e.Item.DataItem("Description"),
    >> "")
    >> Dim ttDateStart As String = IIf(Not
    >> IsDBNull(e.Item.DataItem("DateStart")),
    >> CDate(e.Item.DataItem("DateStart")).ToShortDateString, "")
    >> Dim ttDateDue As String = IIf(Not
    >> IsDBNull(e.Item.DataItem("DateDue")),
    >> CDate(e.Item.DataItem("DateDue")).ToShortDateString, "")
    >>
    >> Dim ToolTip As New System.Text.StringBuilder
    >>
    >> ' First I build the text
    >> ToolTip.Append("Title: " & ttTitle & "<br /><br />")
    >> If ttDesc <> "" Then ToolTip.Append(ttDesc & "<br /><br />")
    >> ToolTip.Append("Start Date: " & ttDateStart & "<br />Due Date: " &
    >> ttDateDue)
    >>
    >> ' Once I have finished I push the value into the description.
    >> e.Item.DataItem("Description") = ToolTip
    >>
    >> End If
    >> End Sub
    >>
    >> On the HTML side I use the following in the <ItemTemplate> of the
    >> Repeater Control.
    >> ...<td.... onMouseover="ddrivetip('<%#DataBinder.Eval(Container,
    >> "DataItem.Description")%>','#284461', 300)">...
    >>
    >> Any Iteas?
    >>
    >> Thanks,
    >> Bryan
    >>

    >
    >
     
    Bryan, Oct 26, 2004
    #3
    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. René Paschold

    Re: ItemDataBound in Repeater: FYI

    René Paschold, Oct 14, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    437
    René Paschold
    Oct 16, 2003
  2. Josh Daws
    Replies:
    2
    Views:
    22,324
    Claes
    Sep 11, 2006
  3. =?Utf-8?B?S2V2aW4gSGVjdG9y?=

    Repeater ItemCreated vs ItemDataBound

    =?Utf-8?B?S2V2aW4gSGVjdG9y?=, Apr 11, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    10,215
    Teemu Keiski
    Apr 11, 2004
  4. Bryan
    Replies:
    1
    Views:
    3,590
    =?Utf-8?B?SEFSSSBQUkFTRCBCQVJV?=
    Oct 26, 2004
  5. adiel
    Replies:
    1
    Views:
    380
    adiel
    Jul 17, 2003
Loading...

Share This Page