Ana, maybe you could place your .aspx and .aspx.vb codes in here: http://dotnetdevelopment.pastebin.com/
This way, we could try to replicate the error. Anyway, if you want, you may send me your files also and I'll try answer you later. On Tue, Oct 20, 2009 at 3:01 PM, Ana <[email protected]> wrote: > > Hi Paulo, > > I tried including the EmptyDataText = "EMPTY FORM VIEW" and my > FormView is just not showing up! Even if I include Visible = "True"! > About the use of my FormView, I will not only be displaying the Label. > I will have a couple DropDownLists populated from the Database, a > Label and some TextBoxes. The label I'm using is just to display an ID > (which I obtain from another Label, outside the FormView) > > I will take a look in the links you sent me and see if it helps. > > Thanks again, > > Ana > > On Oct 20, 9:44 am, Paulo Roberto Pellucci <[email protected]> > wrote: > > Your code isn't wrong Ana, the point is that the FormView control won't > > render the label if there's no data related to it. > > > > An example to illustrate, changeyour FormView control to this one (just > the > > header part) and run the application: > > <asp:FormView ID="myFormView" runat="server" SkinID="DetailsFormview" > > EmptyDataText="I am empty!"> > > > > When you run, you'll see that the FormView renders the "I am empty" > message, > > that means that your FormView is empty, since this message is associated > to > > the EmptyDataText property. > > > > It would help if you share with us what is the behavior you're expecting. > If > > you just want to see a label, place it outside the FormView. > > > > <table width="400"> > > <tr> > > <td align="right"> > > <b>This is the label: </b> > > </td> > > <td align="left"> > > <asp:Label ID="myLabel" Text="Label Text" > > runat="server" /> > > </td> > > </tr> > > </table> > > <asp:FormView ID="myFormView" runat="server" SkinID="DetailsFormview"> > > <ItemTemplate> > > </ItemTemplate> > > </asp:FormView> > > > > I would recommend you to read what the FormView can be used to: > http://msdn.microsoft.com/en-us/library/ms227992.aspxhttp://www.dotnetfunda.com/tutorials/controls/formview.aspxhttp://www.aspnettutorials.com/tutorials/database/formviewdata-vb.aspx > > > > > > > > On Tue, Oct 20, 2009 at 1:35 PM, Ana <[email protected]> > wrote: > > > > > Hi Paulo, > > > > > Thanks for you reply! I modified my code and everything I have now is > > > this: > > > > > <asp:FormView ID="myFormView" runat="server" SkinID="DetailsFormview"> > > > <ItemTemplate> > > > <table width="400"> > > > <tr> > > > <td align="right"> > > > <b>This is the label: </b> > > > </td> > > > <td align="left"> > > > <asp:Label ID="myLabel" Text="Label Text" > > > runat="server" /> > > > </td> > > > </tr> > > > </table> > > > </ItemTemplate> > > > </asp:FormView> > > > > > And in the code behind: > > > > > Protected Sub BindFormView() > > > Dim myLabel As Label = myFormView.FindControl("myLabel") > > > myLabel.Text = AnotherLabel.Text > > > End Sub > > > > > However, myLabel is still nothing. :( Do you suggest anything? > > > > > On Oct 19, 7:56 pm, Paulo Roberto Pellucci <[email protected]> > > > wrote: > > > > Ana, > > > > > > the label will not exist in the page if the content was not bindable > yet. > > > > > > I mean, the control will only be rendered if there is a datasource > linked > > > on > > > > it and it you've invoked the myFormView.DataBind() method. > > > > > > Another thing, if you place this control into <InsertItemTemplate> > tags, > > > it > > > > will only be visible when the FormView is in insert mode. > > > > I don't know if you want that behavior, but, the correct would be > > > > <ItemTemplate> tags instead. > > > > > > Hope you understood. > > > > > > On Mon, Oct 19, 2009 at 8:49 PM, Ana <[email protected]> > > > wrote: > > > > > > > Hi, > > > > > > > My question is quite simple but I can't find the solution. > > > > > I have a FormView inside a div and, inside the formview, I have an > > > > > InsertItemTemplate. In this InsertItemTemplate, I have a Label that > I > > > > > need to access in the code behind. My code is as follows: > > > > > > > <div id="myDiv" runat="server"> > > > > > <asp:FormView ID="myFormView" runat="server" > > > > > SkinID="DetailsFormview"> > > > > > <InsertItemTemplate> > > > > > <table width="400"> > > > > > <tr> > > > > > <td align="right"> > > > > > <b>Label: </b> > > > > > </td> > > > > > <td align="left"> > > > > > <asp:Label ID="myLabel" runat="server" > /> > > > > > </td> > > > > > </tr> > > > > > </table> > > > > > </InsertItemTemplate> > > > > > </asp:FormView> > > > > > </div> > > > > > > > I tried the following: > > > > > > > Dim myLabel As Label = CType(myFormView.FindControl("myLabel"), > Label) > > > > > > > But myLabel is always Nothing :( > > > > > > > How do I get the control then? > > > > > > > Thanks a lot, > > > > > > > Ana > > > > > > -- > > > > Atenciosamente, > > > > Paulo Roberto S. Pellucci > > > > -- > > Atenciosamente, > > Paulo Roberto S. Pellucci > -- Atenciosamente, Paulo Roberto S. Pellucci
