Adding a System.Web.UI.WebControls.Panel to a DataGrid Cell

Discussion in 'ASP .Net' started by kito, Sep 7, 2006.

  1. kito

    kito Guest

    I have the following problem. I have a list of products in a Database.
    Now I would like to list them on a DataGrid, but in a special manner.
    In the first cell of a row in the DataGrid I would like to put the
    product-image (which is also not a problem) and in the second cell of
    the DataGrid I would like to put a Panel or something, where I add
    several things, like the title, description, price ... of the product
    and also controls such as ImageButtons or something that do an action.

    The caption of the actions of the imageButtons is not the problem. My
    problem is that I'm not able to put a label into the datagrid-cell. I
    could use a template column, but the problem is that all this stuff has
    to be created dynamically from the database.

    It must also not be a panel. It can also be some other control, where I
    can add controls like buttons etc..

    I hope everybody understands my problem, it is kind of difficult to
    explain clearly.

    Juri
     
    kito, Sep 7, 2006
    #1
    1. Advertisements

  2. kito

    Arsen V. Guest

    Juri,

    You should use the TemplateColumn and use DataBinder.Eval (or just Eval() in
    ..NET2) to populate the proper labels, textboxes, etc.

    Take a look at the following examples:

    ..NET 1.x
    http://samples.gotdotnet.com/quicks...s/intro/Intro9.src&file=CS\Intro9.aspx&font=3

    accessible from here: http://samples.gotdotnet.com/quickstart/aspplus/
    (Intro 9.aspx)

    ..NET 2.0
    http://quickstarts.asp.net/QuickSta...~/aspnet/samples/data/PhotosDataListPlain.src
    accessible from here
    http://quickstarts.asp.net/QuickStartv20/aspnet/doc/data/templates.aspx#expressions
    (C# DataBinding in a Datalist Template)

    -AV
     
    Arsen V., Sep 7, 2006
    #2
    1. Advertisements

  3. kito

    kito Guest

    Thanks Arsen,

    Your links helped me a lot. It works now, the only problem I have now
    is that I cannot switch to design-view.
    I have statements now such as:
    <table border="1">
    <tr>
    <td valign="center"><img src="<%#Container.DataItem("imageURL")%>">
    </td>
    </tr>
    </table>

    I get the following error:
    "Could not open in Design view. Quote values differently inside a
    '<%..."value"...%>' block."

    I tried to quote them differently trying the combination of
    '...."value"....' and in the reverse order ".....'value'...."!
    The second one doesn't even work, in the first case I get the image or
    value quoted with '.
    I looked up on the net, tried the solutions found there, but nothing
    really works...
    It's a little bit uncomfortable every time to comment out this part,
    switching to design view and then when testing the app, activate the
    part again...
     
    kito, Sep 10, 2006
    #3
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.