Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Jeronimo Bertran #1
.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
-
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... -
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... -
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... -
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. ... -
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... -
Steven Cheng[MSFT] #2
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
-
Jeronimo Bertran #3
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
-
Jeronimo Bertran #4
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
-
Steven Cheng[MSFT] #5
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
-
Jeronimo Bertran #6
RE: .net 2.0 FormView questions
Thanks Steven... worked great.
Jeronimo
Jeronimo Bertran Guest
-
Steven Cheng[MSFT] #7
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



Reply With Quote

