.net 2.0 FormView questions

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default .net 2.0 FormView questions

    Hello,

    I have a couple of questions about the FormView control.

    How can I access the controls I add to the ItemTemplate from the code
    behind file? For example, I added a button named Button1 to the
    ItemTemplate and I want to modify it from the codebehind.

    Can I set the pager to appear on top of the FormView just like it is done
    in the DetailsView?

    If the number of fields on my record is too large, is there a way to
    separate the fields into multiple pages in a FormView? I was thinking of
    creating a single ItemTemplate with panels that contain the controls and
    add buttons to hide and show panels within the ItemTemplate. I would need
    to do the same for the Insert and Edit templates.

    Thanks

    Jeronimo

    Jeronimo Bertran Guest

  2. Similar Questions and Discussions

    1. Dropdown list using Formview
      I am using a Formview to insert data. I need to make 2 dropdownlist depend on each other. The first dropdownlist is easy to fill it (contains...
    2. Creating a reusable dropdownlist for use in formview
      Hi I need to create a dropdownlist for reusing in a lot of formviews, with databinding. If I create a user control the selectedvalue is not...
    3. CustomBinding in a FormView
      I have a FormView control on my page with, among other things, a ListBox control bound to a sqlDataSource. In the EditItemTemplate, I want that...
    4. FormView Control
      I would like to insert some number of Form View Controls onto a single web page in the code behind file. The number to be determined at run time. ...
    5. FormView inheritance question
      I've recently attempted to inherit the FormView control, simply to remove the ungodly table element it renders around your template markup. I'm not...
  3. #2

    Default RE: .net 2.0 FormView questions

    Hi Jeronimo,

    Welcome to ASPNET newsgroup.
    As for the formview questions you mentioned, here are some of my
    understanding and suggestion:

    1.For controls declared in Itemtemplate, we can access them through
    FormView.Row.FindControl(controlID)

    as long as the FormView is currently in normal readonly mode.

    2.For pager, we can set it to display at top of the FormView through the
    pagerSetting template like

    .................
    <PagerSettings Position="Top" />
    </asp:FormView>

    3. For paging for fields, i'm afraid currently it's not availabe in the
    formview since the buildin paging is records based. If you find that the
    fields count are too large, you can manually define some panel or <span> in
    the ItemTemplate and use some clientscript to let the user show or hide
    them.

    Hope helps. Thanks,


    Steven Cheng
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    --------------------
    | Subject: .net 2.0 FormView questions
    | From: Jeronimo Bertran <jeronimo.bertran@newsgroup.nospam>
    | Organization: Your Company
    | Message-ID: <Xns96F4DDCA784DDpublicjbbertrancom@207.46.248.1 6>
    | User-Agent: Xnews/??.01.30
    | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
    | Date: Wed, 19 Oct 2005 21:48:09 -0700
    | NNTP-Posting-Host: c-069-063-192-218.sd2.redwire.net 69.63.192.218
    | Lines: 1
    | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP14.phx.gbl
    | Xref: TK2MSFTNGXA01.phx.gbl
    microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5827
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
    |
    | Hello,
    |
    | I have a couple of questions about the FormView control.
    |
    | How can I access the controls I add to the ItemTemplate from the code
    | behind file? For example, I added a button named Button1 to the
    | ItemTemplate and I want to modify it from the codebehind.
    |
    | Can I set the pager to appear on top of the FormView just like it is done
    | in the DetailsView?
    |
    | If the number of fields on my record is too large, is there a way to
    | separate the fields into multiple pages in a FormView? I was thinking of
    | creating a single ItemTemplate with panels that contain the controls and
    | add buttons to hide and show panels within the ItemTemplate. I would
    need
    | to do the same for the Insert and Edit templates.
    |
    | Thanks
    |
    | Jeronimo
    |
    |

    Steven Cheng[MSFT] Guest

  4. #3

    Default RE: .net 2.0 FormView questions

    Thanks Steven,

    Your were very helpful... so regarding my first question, no control
    variables are created on c# for controls I add to the template the same way
    variables are created for controls that are added to the page?


    [email]stcheng@online.microsoft.com[/email] (Steven Cheng[MSFT]) wrote in
    news:PAo#GuW1FHA.1144@TK2MSFTNGXA01.phx.gbl:
    > Hi Jeronimo,
    >
    > Welcome to ASPNET newsgroup.
    > As for the formview questions you mentioned, here are some of my
    > understanding and suggestion:
    >
    > 1.For controls declared in Itemtemplate, we can access them through
    > FormView.Row.FindControl(controlID)
    >
    > as long as the FormView is currently in normal readonly mode.
    >
    > 2.For pager, we can set it to display at top of the FormView through
    > the pagerSetting template like
    >
    > ................
    > <PagerSettings Position="Top" />
    > </asp:FormView>
    >
    > 3. For paging for fields, i'm afraid currently it's not availabe in
    > the formview since the buildin paging is records based. If you find
    > that the fields count are too large, you can manually define some
    > panel or <span> in the ItemTemplate and use some clientscript to let
    > the user show or hide them.
    >
    > Hope helps. Thanks,
    >
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! [url]www.microsoft.com/security[/url]
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    >
    >
    Jeronimo Bertran Guest

  5. #4

    Default RE: .net 2.0 FormView questions

    Steven,

    A couple of questions regarding hiding some controls based on the
    page....

    I basically added an html button to the headertemplate of the FormView:

    <HeaderTemplate>
    <input id="Button1" type="button" value="button"
    onclick="javascript:ShowHide()" />
    </HeaderTemplate>

    I then grouped a couple of the controls in the ItemTemplate inside a
    DIV:


    <div id="Div1">
    Field1:<asp:Label ID="Field1Label" runat="server" Text='<%# Bind
    ("Field1") %>'></asp:Label><br />
    Field2:<asp:Label ID="Field2Label" runat="server" Text='<%# Eval
    ("Field2") %>'></asp:Label><br />
    </div>
    <div id="Div2">
    Field3:<asp:Label ID="Field3Label" runat="server" Text='<%# Bind
    ("Field3") %>'></asp:Label><br />
    Field4:<asp:Label ID="Field4Label" runat="server" Text='<%# Eval
    ("Field4") %>'></asp:Label><br />
    </div>


    I then added the code to simply hide the div in order to see the
    results:

    function ShowHide()
    {
    var o = document.getElementById('Div1');
    if (o)
    {
    if (o.style.visibility == 'hidden')
    {
    o.style.visibility='visible';
    document.getElementById('Div2').style.visibility=' hidden';
    }
    else
    {
    o.style.visibility='hidden';
    document.getElementById('Div2').style.visibility=' visible';
    }
    }

    }

    This does hide the content inside DIV1 when I press the button and shows
    the contents of DIV2, but the space taken by each DIV remains blank
    after hiding and therefore it is like having an empty page before we get
    to the controls on the second DIV.

    I tried using an asp:Panel instead of the div.... but I am unable to
    access the panel from my script.... I basically change the DIV1 tag to
    the following:

    <asp:Panel ID="Div1" runat="server">

    but now getElementByID('Div1') return null.

    THanks again,

    Jeronimo





    Jeronimo Bertran Guest

  6. #5

    Default RE: .net 2.0 FormView questions

    Hi Jeronimo,

    Thanks for your response.

    For your question in the first response
    ===========
    so regarding my first question, no control
    variables are created on c# for controls I add to the template the same way
    variables are created for controls that are added to the page?
    ===================

    Yes, for sub controls nested in other container controls on the page, there
    won't have direct control property in page class to access them. Only top
    level controls has such member properties in page.

    As for the showhide function, you can use the following code instead of
    your original one:

    =================================
    function showhidetwo()
    {
    var div = document.getElementById("divTwo");
    if(div.style.display != "none")
    {
    div.style.display = "none";
    }else
    {
    div.style.display = "inline";
    }
    }
    ============================

    the style.display can help hidden the html element and won't occupy the
    space as well.

    Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    --------------------
    | Subject: RE: .net 2.0 FormView questions
    | From: Jeronimo Bertran <jeronimo.bertran@newsgroup.nospam>
    | References: <Xns96F4DDCA784DDpublicjbbertrancom@207.46.248.1 6>
    <PAo#GuW1FHA.1144@TK2MSFTNGXA01.phx.gbl>
    | Organization: Your Company
    | Message-ID: <Xns96F5A10B4DFDCpublicjbbertrancom@207.46.248.1 6>
    | User-Agent: Xnews/??.01.30
    | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
    | Date: Thu, 20 Oct 2005 15:49:50 -0700
    | NNTP-Posting-Host: c-069-063-192-218.sd2.redwire.net 69.63.192.218
    | Lines: 1
    | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl
    | Xref: TK2MSFTNGXA01.phx.gbl
    microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5840
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
    |
    | Steven,
    |
    | A couple of questions regarding hiding some controls based on the
    | page....
    |
    | I basically added an html button to the headertemplate of the FormView:
    |
    | <HeaderTemplate>
    | <input id="Button1" type="button" value="button"
    | onclick="javascript:ShowHide()" />
    | </HeaderTemplate>
    |
    | I then grouped a couple of the controls in the ItemTemplate inside a
    | DIV:
    |
    |
    | <div id="Div1">
    | Field1:<asp:Label ID="Field1Label" runat="server" Text='<%# Bind
    | ("Field1") %>'></asp:Label><br />
    | Field2:<asp:Label ID="Field2Label" runat="server" Text='<%# Eval
    | ("Field2") %>'></asp:Label><br />
    | </div>
    | <div id="Div2">
    | Field3:<asp:Label ID="Field3Label" runat="server" Text='<%# Bind
    | ("Field3") %>'></asp:Label><br />
    | Field4:<asp:Label ID="Field4Label" runat="server" Text='<%# Eval
    | ("Field4") %>'></asp:Label><br />
    | </div>
    |
    |
    | I then added the code to simply hide the div in order to see the
    | results:
    |
    | function ShowHide()
    | {
    | var o = document.getElementById('Div1');
    | if (o)
    | {
    | if (o.style.visibility == 'hidden')
    | {
    | o.style.visibility='visible';
    | document.getElementById('Div2').style.visibility=' hidden';
    | }
    | else
    | {
    | o.style.visibility='hidden';
    | document.getElementById('Div2').style.visibility=' visible';
    | }
    | }
    |
    | }
    |
    | This does hide the content inside DIV1 when I press the button and shows
    | the contents of DIV2, but the space taken by each DIV remains blank
    | after hiding and therefore it is like having an empty page before we get
    | to the controls on the second DIV.
    |
    | I tried using an asp:Panel instead of the div.... but I am unable to
    | access the panel from my script.... I basically change the DIV1 tag to
    | the following:
    |
    | <asp:Panel ID="Div1" runat="server">
    |
    | but now getElementByID('Div1') return null.
    |
    | THanks again,
    |
    | Jeronimo
    |
    |
    |
    |
    |
    |

    Steven Cheng[MSFT] Guest

  7. #6

    Default RE: .net 2.0 FormView questions

    Thanks Steven... worked great.

    Jeronimo
    Jeronimo Bertran Guest

  8. #7

    Default RE: .net 2.0 FormView questions

    You're welcome Jeronimo,

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    --------------------
    | Subject: RE: .net 2.0 FormView questions
    | From: Jeronimo Bertran <jeronimo.bertran@newsgroup.nospam>
    | References: <Xns96F4DDCA784DDpublicjbbertrancom@207.46.248.1 6>
    <PAo#GuW1FHA.1144@TK2MSFTNGXA01.phx.gbl>
    <Xns96F5A10B4DFDCpublicjbbertrancom@207.46.248.1 6>
    <JAy9Rgg1FHA.1144@TK2MSFTNGXA01.phx.gbl>
    | Organization: Your Company
    | Message-ID: <Xns96F9C84C3CCE8publicjbbertrancom@207.46.248.1 6>
    | User-Agent: Xnews/??.01.30
    | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
    | Date: Mon, 24 Oct 2005 19:41:19 -0700
    | NNTP-Posting-Host: c-069-063-192-218.sd2.redwire.net 69.63.192.218
    | Lines: 1
    | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP15.phx.gbl
    | Xref: TK2MSFTNGXA01.phx.gbl
    microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5855
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
    |
    | Thanks Steven... worked great.
    |
    | Jeronimo
    |

    Steven Cheng[MSFT] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139