|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Adding a System.Web.UI.WebControls.Panel to a DataGrid CellNow 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 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/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/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/QuickStartv20/util/srcview.aspx?path=~/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 Show quote "kito" <juri.strumpfloh***@gmail.com> wrote in message news:1157660789.117007.127580@p79g2000cwp.googlegroups.com... > 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 > 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... |
|||||||||||||||||||||||