How to add a small HTML table under a row of a GridView

O

onearth

Hello

I tried this.. what i did:

1) I added to my Grid ASPX - <%@ Register TagPrefix="pflr" TagName
="pflr" Src= "DBMatesUsrCntrl.ascx" %>
2) I created a new usercontrol and pasted the following code (same code
as yours, but i changed the field names to fit my database)
<%@ Control Language="C#" ClassName="DBMatesUsrCntrl" %>
<asp:TemplateField HeaderText="Gegevens">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Trim(
Server.HtmlEncode(
Eval("CustomerID").ToString & " " & Eval("CustomerName").ToString & " "
&
Eval("CustomerAddress").ToString ) ).replace( " ", " " ).Replace( " ",
"&nbsp;" )
& "<BR>" & BankOfGiro( Eval("CustomerPhone").ToString,
Eval("CustomerPhone2").ToString, Eval("CustomerPhone3" ).ToString,
Eval("CustomerPhone4" ).ToString ) %>'></asp:Label>
<pflr:pflr ID="pflr1" runat="server" />
</ItemTemplate>
<ItemStyle Wrap="False" />
</asp:TemplateField>

I get error in the UserControl: Error: Unknown server tag 'pflr:pflr'.
and
Error:Unrecognized tag prefix or device filter 'pflr'.
and
Error:Element 'Label' is not a known element. This can occur if there
is a compilation error in the Web site.

I guess i am doing something wrong.. :(
 
E

Edwin Knoppert

(Actually THIS is the right moment for you to mess with it for a while)

Start the easy way first, one main aspx which shows a usercontrol.
The usercontrol by default is named: ClassName="WebUserControl1"

Mine is changed to:

(asxc)
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="licreg.ascx.vb"
Inherits="pflr" %>

(asxc.vb)
Partial Class pflr
Inherits System.Web.UI.UserControl
etc..

This is enough info for you to try it for today :)

Once you have this run, you can build anything cool with the itemtemplate
stuff.
Do note that you need to type the control, then once in visual design mode
you can grab it and resize it.
 
O

onearth

I think i am doing something wrong here:

In the UserControl i placed ( just changed the fields names)
<%@ Control Language="C#" ClassName="DBMatesUsrCntrl" %>
<asp:TemplateField HeaderText="Gegevens">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Trim(
Server.HtmlEncode(
Eval("CustomerID").ToString & " " & Eval("CustomerName").ToString & " "
&
Eval("CustomerAddress").ToString ) ).replace( " ", " " ).Replace( " ",
"&nbsp;" )
& "<BR>" & BankOfGiro( Eval("CustomerPhone").ToString,
Eval("CustomerPhone2").ToString, Eval("CustomerPhone3" ).ToString,
Eval("CustomerPhone4" ).ToString ) %>'></asp:Label>
<pflr:pflr ID="pflr1" runat="server" />
</ItemTemplate>
<ItemStyle Wrap="False" />
</asp:TemplateField>

In the Grid ASPX i placed: <%@ Register TagPrefix="pflr" TagName
="pflr" Src= "DBMatesUsrCntrl.ascx" %>

and i get the errors in the user control:

Unknown server tag 'pflr:pflr'.
Unrecognized tag prefix or device filter 'pflr'.
Element 'Label' is not a known element. This can occur if there is a
compilation error in the Web site.

Not sure what i am doing wrong here...:\
 
O

onearth

Thank you very much Edwin.. I will play with this tomorrow..

I still need to consider that i need to bound the user control from
code since i add the new label from code also.. actually i just need
to bound the user control from code it self (code behind) since i do
everything from code in order to be able to add a new "table" below the
selected row of the GridView..

Thank you again i will mass with it tomorrow when my mind is clearer :)
 
E

Edwin Knoppert

use a property like i already mentioned like Text
Then BIND text using <%#bind("field..")%>
Or eval(), never tested above.

It's all so simple, a label in an itemtemplate also has a text property.
It's all the same.
 
E

Edwin Knoppert

Hmm, from codebehind, don't know what you mean but maybe you mean a
datafield property.
??
We'll see :)
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,157
Latest member
MercedesE4
Top