|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to add a small HTML table under a row of a GridViewHello
I already managed to add a dynamic DetailView under a row of Gridview if a user presses the row with the mouse... Is it possible to add under it a table(or even better load a simple HTML file that contains the tables).. not a detailview like I already did..Because i would like to be able to design the table as i wish and not to be limited to the DetailView Design which only contains rows & coluwns. I want totally new design.... I really need this if anyone knows.. so please :) I often use resources.
You could embed the html as resource and still design it. Maybe a little bit last-minute stripping or so? (removing tags) Show quoteHide quote "onearth" <ddd***@013.net> schreef in bericht news:1132863108.048194.27850@g14g2000cwa.googlegroups.com... > Hello > > I already managed to add a dynamic DetailView under a row of Gridview > if a user presses the row with the mouse... > > Is it possible to add under it a table(or even better load a simple > HTML file that contains the tables).. not a detailview like I already > did..Because i would like to be able to design the table as i wish and > not to be limited to the DetailView Design which only contains rows & > coluwns. > I want totally new design.... > > I really need this if anyone knows.. > so please :) > Hello Edwin..
What do you mean embed the html as a resoruce... What object does this? Start new project (or existing)
Add special folder: App_GlobalResources Add in this folder a resource: Resource.resx (new item) Add the html to that folder (evt refresh). Open Resource.resx, something with string is shown, forget that. Just drag the html in the new screen, a pretty large image with the filename is now shown. Close, go to any page_load or whatever code. To get a string: Dim T as String = Resources.Resource.thefilenamehere.ToString And so you can insert the html as styring into any trag you like :) Note the codetip will show present resources after: Resources.Resource.... Show quoteHide quote "onearth" <ddd***@013.net> schreef in bericht news:1132865951.682701.138340@g49g2000cwa.googlegroups.com... > Hello Edwin.. > > What do you mean embed the html as a resoruce... What object does this? > (Not trag but tag like <%= Resources.Resource.blabla.Tostring %>
Show quoteHide quote :) "Edwin Knoppert" <i***@pbsoft.speedlinq.nl> schreef in bericht news:dm5agb$ndp$1@azure.qinip.net... > Start new project (or existing) > Add special folder: App_GlobalResources > Add in this folder a resource: Resource.resx (new item) > Add the html to that folder (evt refresh). > Open Resource.resx, something with string is shown, forget that. > Just drag the html in the new screen, a pretty large image with the > filename is now shown. > Close, go to any page_load or whatever code. > > To get a string: > Dim T as String = Resources.Resource.thefilenamehere.ToString > > And so you can insert the html as styring into any trag you like :) > > Note the codetip will show present resources after: Resources.Resource.... > > "onearth" <ddd***@013.net> schreef in bericht > news:1132865951.682701.138340@g49g2000cwa.googlegroups.com... >> Hello Edwin.. >> >> What do you mean embed the html as a resoruce... What object does this? >> > > It's silly but i tested the html by embedding it into the aspx.
Of course <html> twice isn't good but it worked: ...... </form> </body> <%=Resources.Resource.HTMLPage.ToString%> </html> Show quoteHide quote "Edwin Knoppert" <i***@pbsoft.speedlinq.nl> schreef in bericht news:dm5aio$ngu$1@azure.qinip.net... > (Not trag but tag like <%= Resources.Resource.blabla.Tostring %> > > :) > > "Edwin Knoppert" <i***@pbsoft.speedlinq.nl> schreef in bericht > news:dm5agb$ndp$1@azure.qinip.net... >> Start new project (or existing) >> Add special folder: App_GlobalResources >> Add in this folder a resource: Resource.resx (new item) >> Add the html to that folder (evt refresh). >> Open Resource.resx, something with string is shown, forget that. >> Just drag the html in the new screen, a pretty large image with the >> filename is now shown. >> Close, go to any page_load or whatever code. >> >> To get a string: >> Dim T as String = Resources.Resource.thefilenamehere.ToString >> >> And so you can insert the html as styring into any trag you like :) >> >> Note the codetip will show present resources after: >> Resources.Resource.... >> >> "onearth" <ddd***@013.net> schreef in bericht >> news:1132865951.682701.138340@g49g2000cwa.googlegroups.com... >>> Hello Edwin.. >>> >>> What do you mean embed the html as a resoruce... What object does this? >>> >> >> > > Hello
Thank you a lot for this example!... Something i have missing is if i create this HTML from CODE Behind since i want to be able to create for each ROW of the gridview an HTML file to display below it.. if i could create the HTML from codebehind that would be helpul.. It might be easier to prepare a usercontrol?
Or at least more solid since html stuff is correct then. Show quoteHide quote "onearth" <ddd***@013.net> schreef in bericht news:1132906029.277739.220950@g44g2000cwa.googlegroups.com... > Hello > > Thank you a lot for this example!... > > Something i have missing is if i create this HTML from CODE Behind > since i want to be able to create for each ROW of the gridview an HTML > file to display below it.. if i could create the HTML from codebehind > that would be helpul.. > Is this a question?
Some kind of dynamic html? Show quoteHide quote "onearth" <ddd***@013.net> schreef in bericht news:1132906029.277739.220950@g44g2000cwa.googlegroups.com... > Hello > > Thank you a lot for this example!... > > Something i have missing is if i create this HTML from CODE Behind > since i want to be able to create for each ROW of the gridview an HTML > file to display below it.. if i could create the HTML from codebehind > that would be helpul.. > Hello
I have tried your solution and indeed it is nice... didn't know about the resources before.. What i did is: If your press 1 of the rows in a GridView it creates a row below it and in that row I add a label from code. To that label i added the resource of an HTML file like you showed me.. it worked nicely .. Now comes the question if i can bind data from a datasource into that HTML file i bind from the resource so it will display some data (customized with the HTML i add) in that label (HTML actually).. I already tried to use DetailView which works since it contains binding method built-in, but the problem with DetailView is that I couldn't customize its appearance from code so it only shows like the standard DetailView with rows and coluwns.. (I added the DetailView from code, created that object).. If you have a solution for this I will be grateful :) I still recommend you to take a peek at usercontrols.
They are directly embedable into a template item. If you want to change on-the-fly in your html. You could use replace( "%1", eval("mydatafield).tostring ) But that's a problem in-line. So you'll need a wrapper function. I put that in the codebehind and used a public function Public Function ReplaceNow( byval s as string ) AS String Dim shtml as string = ... (your resource) sHtml = shTml.replace( "%1", s ) Return sHTML End Function IN your template (~): <%#ReplaceNow(eval("mydatafield).tostring))%> Show quoteHide quote "onearth" <ddd***@013.net> schreef in bericht news:1132922279.687094.63540@g43g2000cwa.googlegroups.com... > Hello > > I have tried your solution and indeed it is nice... didn't know about > the resources before.. > > What i did is: If your press 1 of the rows in a GridView it creates a > row below it and in that row I add a label from code. To that label i > added the resource of an HTML file like you showed me.. it worked > nicely .. > Now comes the question if i can bind data from a datasource into that > HTML file i bind from the resource so it will display some data > (customized with the HTML i add) in that label (HTML actually).. I > already tried to use DetailView which works since it contains binding > method built-in, but the problem with DetailView is that I couldn't > customize its appearance from code so it only shows like the standard > DetailView with rows and coluwns.. (I added the DetailView from code, > created that object).. > > If you have a solution for this I will be grateful :) > I love resources.
I use them a lot with javascript and SQL statements. No more conversions having chr$( 34) misery etc.. I often use %1 and so on to be replaced, like in queries. Show quoteHide quote :) "onearth" <ddd***@013.net> schreef in bericht news:1132922279.687094.63540@g43g2000cwa.googlegroups.com... > Hello > > I have tried your solution and indeed it is nice... didn't know about > the resources before.. > > What i did is: If your press 1 of the rows in a GridView it creates a > row below it and in that row I add a label from code. To that label i > added the resource of an HTML file like you showed me.. it worked > nicely .. > Now comes the question if i can bind data from a datasource into that > HTML file i bind from the resource so it will display some data > (customized with the HTML i add) in that label (HTML actually).. I > already tried to use DetailView which works since it contains binding > method built-in, but the problem with DetailView is that I couldn't > customize its appearance from code so it only shows like the standard > DetailView with rows and coluwns.. (I added the DetailView from code, > created that object).. > > If you have a solution for this I will be grateful :) > You mean that i can use a usercontrol..
In that UserControl i will make the nice table and also bind the data into that table and display it under the row i wanted? sounds like an easier solution if i get you right.. If i get you right do you know how to add a usercontrol from code behind? I meant i will premake a usercontrol, but i will have to ADD it in
code... I always used usercontrols but i placed them in the HTML not from code :) usercontrols do not work with .htm files, only .aspx
but i think you got that. Show quoteHide quote "onearth" <ddd***@013.net> schreef in bericht news:1132924827.986713.277970@g14g2000cwa.googlegroups.com... >I meant i will premake a usercontrol, but i will have to ADD it in > code... I always used usercontrols but i placed them in the HTML not > from code :) > I guess you could change things on-the-fly.
In fact i do the same with a label in a gridview, why should it be different Here is a snapshot of a line required to let the aspx know that there is a usercontrol (so no need to compile). <%@ Register TagPrefix="pflr" TagName ="pflr" Src= "~/licreg.ascx" %> ..... <form id="form1" runat="server"> <div> <pflr:pflr ID="pflr1" runat="server" /> <br /> etc.. Afaik, the tagname and prefix should differ i guess, it does work though :) Show quoteHide quote "onearth" <ddd***@013.net> schreef in bericht news:1132924399.997956.158910@o13g2000cwo.googlegroups.com... > You mean that i can use a usercontrol.. > In that UserControl i will make the nice table and also bind the data > into that table and display it under the row i wanted? > > sounds like an easier solution if i get you right.. > > If i get you right do you know how to add a usercontrol from code > behind? > >sounds like an easier solution if i get you right.. Yes, but i offered another approach.Use it as it should and not with html. Show quoteHide quote :) "onearth" <ddd***@013.net> schreef in bericht news:1132924399.997956.158910@o13g2000cwo.googlegroups.com... > You mean that i can use a usercontrol.. > In that UserControl i will make the nice table and also bind the data > into that table and display it under the row i wanted? > > sounds like an easier solution if i get you right.. > > If i get you right do you know how to add a usercontrol from code > behind? > Thank you for all the information...
I just want to see if i get it right before i test it: 1) I create an ASPX (not HTML :) ) resource and let it know there is a usercontrol (with "Register" tag). 2) I create a UserControl that contains the table with binding Tags (for data binding) (so i do not use the ReplaceNow function now) 3) I place in the Label (the 1 inside the new row of the GridView) and in that label i put the ASPX code inside.. (MyLabel.Text = Resources.Resource.MYASPXPage.ToString();) 4) Ummm, that is it? :) No forget resources, just create a control.
I just tested, works fine, here is a label + usercontrol. <asp:TemplateField HeaderText="Gegevens"> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Trim( Server.HtmlEncode( Eval("Voornaam").ToString & " " & Eval("TussenVoegsels").ToString & " " & Eval("Achternaam").ToString ) ).replace( " ", " " ).Replace( " ", " " ) & "<BR>" & BankOfGiro( Eval("BankOfGiro").ToString, Eval("BankNummer").ToString, Eval("GiroNummer" ).ToString, Eval("TenNameVan" ).ToString ) %>'></asp:Label> <pflr:pflr ID="pflr1" runat="server" /> </ItemTemplate> <ItemStyle Wrap="False" /> </asp:TemplateField> The register tag needs to be present in the aspx where the grid is. So the page knows of the control. TYPE the control like i did, otherwise you can not see it in visual design. (it's not in the toolsbox) Now mess wit the UC's properties you design. Show quoteHide quote "onearth" <ddd***@013.net> schreef in bericht news:1132925649.686681.41800@g44g2000cwa.googlegroups.com... > Thank you for all the information... > > I just want to see if i get it right before i test it: > > 1) I create an ASPX (not HTML :) ) resource and let it know there is a > usercontrol (with "Register" tag). > 2) I create a UserControl that contains the table with binding Tags > (for data binding) (so i do not use the ReplaceNow function now) > 3) I place in the Label (the 1 inside the new row of the GridView) and > in that label i put the ASPX code inside.. (MyLabel.Text = > Resources.Resource.MYASPXPage.ToString();) > 4) Ummm, that is it? :) > If you look close:
<pflr:pflr ID="pflr1" runat="server" /> This also means you can use the UC's custom properties(!) For example a Text property <pflr:pflr ID="pflr1" runat="server" Text=<%# eval.... %> /> ON text you can modify the UC completely. Show quoteHide quote "Edwin Knoppert" <n***@hellobasic.com> schreef in bericht news:4387155a$0$2333$ba620dc5@text.nova.planet.nl... > > No forget resources, just create a control. > > I just tested, works fine, here is a label + usercontrol. > > <asp:TemplateField HeaderText="Gegevens"> > <ItemTemplate> > <asp:Label ID="Label1" runat="server" Text='<%# Trim( Server.HtmlEncode( > Eval("Voornaam").ToString & " " & Eval("TussenVoegsels").ToString & " " & > Eval("Achternaam").ToString ) ).replace( " ", " " ).Replace( " ", > " " ) & "<BR>" & BankOfGiro( Eval("BankOfGiro").ToString, > Eval("BankNummer").ToString, Eval("GiroNummer" ).ToString, > Eval("TenNameVan" ).ToString ) %>'></asp:Label> > <pflr:pflr ID="pflr1" runat="server" /> > </ItemTemplate> > <ItemStyle Wrap="False" /> > </asp:TemplateField> > > The register tag needs to be present in the aspx where the grid is. > So the page knows of the control. > TYPE the control like i did, otherwise you can not see it in visual > design. > (it's not in the toolsbox) > Now mess wit the UC's properties you design. > > > > "onearth" <ddd***@013.net> schreef in bericht > news:1132925649.686681.41800@g44g2000cwa.googlegroups.com... >> Thank you for all the information... >> >> I just want to see if i get it right before i test it: >> >> 1) I create an ASPX (not HTML :) ) resource and let it know there is a >> usercontrol (with "Register" tag). >> 2) I create a UserControl that contains the table with binding Tags >> (for data binding) (so i do not use the ReplaceNow function now) >> 3) I place in the Label (the 1 inside the new row of the GridView) and >> in that label i put the ASPX code inside.. (MyLabel.Text = >> Resources.Resource.MYASPXPage.ToString();) >> 4) Ummm, that is it? :) >> > > 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( " ", " " ) & "<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.. :( (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. Show quoteHide quote "onearth" <ddd***@013.net> schreef in bericht news:1132930825.030532.13840@g49g2000cwa.googlegroups.com... > 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( " ", > " " ) > & "<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.. :( > 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( " ", " " ) & "<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...:\ Check this out:
http://s39.yousendit.com/d.aspx?id=3B2BVLKDDP9HI2Y5BBDDNCZ6I8 Show quoteHide quote "onearth" <ddd***@013.net> schreef in bericht news:1132932159.841233.323680@g43g2000cwa.googlegroups.com... >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( " ", > " " ) > & "<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...:\ > 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 :) 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. Show quoteHide quote "onearth" <ddd***@013.net> schreef in bericht news:1132941925.405223.258830@g43g2000cwa.googlegroups.com... > 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 :) > Hmm, from codebehind, don't know what you mean but maybe you mean a
datafield property. ?? We'll see :) Show quoteHide quote "onearth" <ddd***@013.net> schreef in bericht news:1132941925.405223.258830@g43g2000cwa.googlegroups.com... > 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 :) >
Other interesting topics
Application["TotalPlayings"]++ doesn't work
Source Control Products??? Correct syntax for an update stored procedure About web.config file Setting Profile properties for not logged in users Dynamic content problem Some questions about masterpages. how load one frame before another in aspx page The server tag is not well formed Finding DataKey in GridView |
|||||||||||||||||||||||