Render blocks and DataBinder making me CRAZY!!!!!

Discussion in 'ASP .Net' started by lh, Oct 17, 2004.

  1. lh

    lh Guest

    I'm trying to pass the values from the databinder.eval statmetn into a
    method in the codebehind. The code below is within a Repeater.
    The error that i'm currently getting is
    Compiler Error Message: CS1502: The best overloaded method match for
    'projectName.dspBranchAdministration.ShowPreview(string)' has some invalid
    arguments

    What is wrong?

    Thanks


    //asp.net within repeater class
    <ItemTemplate>
    <tr>
    <td><%# DataBinder.Eval(Container.DataItem,"vcBranch")%></td> //shows
    properly
    <td><a href='dspEditBranch.aspx?intBranch=<%#
    DataBinder.Eval(Container.DataItem,"ridBranch")%>&chk=<%#
    projectName.Utility.GetRandomString(DataBinder.Eval(Container.DataItem,"ridB
    ranch").ToString())%>' class="button">Edit</a></td>
    <%# ShowPreview(DataBinder.Eval(Container.DataItem,"vcBranch"))%>
    //doesnt work
    </tr>
    </ItemTemplate>


    //in codebehind
    protected string ShowPreview(string sitehost)

    {

    return "<td>wtf</td>";

    }
     
    lh, Oct 17, 2004
    #1
    1. Advertising

  2. If you have real complex expressions it sometimes works better if you create
    a method at the form level and call that instead of nesting statements too
    deep in the databinding expressions. I've had major headaches with this as
    well and using a simplified method usually solves the problem. Most likely
    that method will also be faster as it won't have to eval expressions in many
    cases only the single method call.

    Actually, looking at your code I think the problem is that the parameters to
    your funciton need to be properly cast. Try using (string) in front of the
    Databinder.Eval().

    Regards,

    +++ RIck ---

    --

    Rick Strahl
    West Wind Technologies
    http://www.west-wind.com/
    http://www.west-wind.com/weblog/
    http://www.west-wind.com/wwThreads/
    ----------------------------------
    Making waves on the Web


    "lh" <> wrote in message
    news:...
    > I'm trying to pass the values from the databinder.eval statmetn into a
    > method in the codebehind. The code below is within a Repeater.
    > The error that i'm currently getting is
    > Compiler Error Message: CS1502: The best overloaded method match for
    > 'projectName.dspBranchAdministration.ShowPreview(string)' has some invalid
    > arguments
    >
    > What is wrong?
    >
    > Thanks
    >
    >
    > //asp.net within repeater class
    > <ItemTemplate>
    > <tr>
    > <td><%# DataBinder.Eval(Container.DataItem,"vcBranch")%></td> //shows
    > properly
    > <td><a href='dspEditBranch.aspx?intBranch=<%#
    > DataBinder.Eval(Container.DataItem,"ridBranch")%>&chk=<%#
    >

    projectName.Utility.GetRandomString(DataBinder.Eval(Container.DataItem,"ridB
    > ranch").ToString())%>' class="button">Edit</a></td>
    > <%# ShowPreview(DataBinder.Eval(Container.DataItem,"vcBranch"))%>
    > //doesnt work
    > </tr>
    > </ItemTemplate>
    >
    >
    > //in codebehind
    > protected string ShowPreview(string sitehost)
    >
    > {
    >
    > return "<td>wtf</td>";
    >
    > }
    >
    >
     
    Rick Strahl [MVP], Oct 18, 2004
    #2
    1. Advertising

  3. lh

    lh Guest

    Doh! That did it. Thanks
    "Rick Strahl [MVP]" <> wrote in message
    news:...
    > If you have real complex expressions it sometimes works better if you

    create
    > a method at the form level and call that instead of nesting statements too
    > deep in the databinding expressions. I've had major headaches with this as
    > well and using a simplified method usually solves the problem. Most likely
    > that method will also be faster as it won't have to eval expressions in

    many
    > cases only the single method call.
    >
    > Actually, looking at your code I think the problem is that the parameters

    to
    > your funciton need to be properly cast. Try using (string) in front of the
    > Databinder.Eval().
    >
    > Regards,
    >
    > +++ RIck ---
    >
    > --
    >
    > Rick Strahl
    > West Wind Technologies
    > http://www.west-wind.com/
    > http://www.west-wind.com/weblog/
    > http://www.west-wind.com/wwThreads/
    > ----------------------------------
    > Making waves on the Web
    >
    >
    > "lh" <> wrote in message
    > news:...
    > > I'm trying to pass the values from the databinder.eval statmetn into a
    > > method in the codebehind. The code below is within a Repeater.
    > > The error that i'm currently getting is
    > > Compiler Error Message: CS1502: The best overloaded method match for
    > > 'projectName.dspBranchAdministration.ShowPreview(string)' has some

    invalid
    > > arguments
    > >
    > > What is wrong?
    > >
    > > Thanks
    > >
    > >
    > > //asp.net within repeater class
    > > <ItemTemplate>
    > > <tr>
    > > <td><%# DataBinder.Eval(Container.DataItem,"vcBranch")%></td>

    //shows
    > > properly
    > > <td><a href='dspEditBranch.aspx?intBranch=<%#
    > > DataBinder.Eval(Container.DataItem,"ridBranch")%>&chk=<%#
    > >

    >

    projectName.Utility.GetRandomString(DataBinder.Eval(Container.DataItem,"ridB
    > > ranch").ToString())%>' class="button">Edit</a></td>
    > > <%# ShowPreview(DataBinder.Eval(Container.DataItem,"vcBranch"))%>
    > > //doesnt work
    > > </tr>
    > > </ItemTemplate>
    > >
    > >
    > > //in codebehind
    > > protected string ShowPreview(string sitehost)
    > >
    > > {
    > >
    > > return "<td>wtf</td>";
    > >
    > > }
    > >
    > >

    >
    >
     
    lh, Oct 18, 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. Lau Lei Cheong

    Page.Render do not render complete page

    Lau Lei Cheong, May 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,075
    Lau Lei Cheong
    May 15, 2004
  2. Nathan Sokalski

    Making an email link with DataBinder.Eval

    Nathan Sokalski, Jul 11, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,142
    Ken Tucker [MVP]
    Jul 11, 2005
  3. matt
    Replies:
    1
    Views:
    273
    George Ogata
    Aug 6, 2004
  4. Glenn Gillen
    Replies:
    0
    Views:
    280
    Glenn Gillen
    Nov 17, 2006
  5. Steven Taylor
    Replies:
    9
    Views:
    256
    Brian Candler
    Apr 27, 2009
Loading...

Share This Page