473,795 Members | 2,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP 2.0 databound controls and code behind

Hi:

The new databound controls (GridView, DetailsView, ect.) use declaritive
syntax (i.e, setup in HTML at design time). However, at times sql
statements and parameters may need to be derived at runtime. In ASP 1.0 we
could do this in code behind, but how do we do it in ASP 2.0? The examples
I see are setting up controls compeletly at design time.

Thanks,
Charlie
Apr 20 '06 #1
2 1718
You can do whatever you want with a GridView at runtime, e.g.
GridView gv = new GridView();
gv.HeaderRow.Ce lls.Add(new TableCell());
gv.Width = 500;
gv.AllowSorting = true;
gv.DataSource = MyDataSet();
// ...etc
this.PlaceHolde r1.Controls.Add (gv);
gv.DataBind();

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Charlie@CB FC" wrote:
Hi:

The new databound controls (GridView, DetailsView, ect.) use declaritive
syntax (i.e, setup in HTML at design time). However, at times sql
statements and parameters may need to be derived at runtime. In ASP 1.0 we
could do this in code behind, but how do we do it in ASP 2.0? The examples
I see are setting up controls compeletly at design time.

Thanks,
Charlie

Apr 20 '06 #2
Hi Peter,
Does setting the datasource like you said, don't you loose the ability to
use the builtin update and delete functionallity. I just rewote a page
because I did it this way and could not get the newvalues or oldvalues to
work. Just wondering. I'm still working on getting my page to commpletely
work with the update, but its coming along.
Michael
"Peter Bromberg [C# MVP]" wrote:
You can do whatever you want with a GridView at runtime, e.g.
GridView gv = new GridView();
gv.HeaderRow.Ce lls.Add(new TableCell());
gv.Width = 500;
gv.AllowSorting = true;
gv.DataSource = MyDataSet();
// ...etc
this.PlaceHolde r1.Controls.Add (gv);
gv.DataBind();

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Charlie@CB FC" wrote:
Hi:

The new databound controls (GridView, DetailsView, ect.) use declaritive
syntax (i.e, setup in HTML at design time). However, at times sql
statements and parameters may need to be derived at runtime. In ASP 1.0 we
could do this in code behind, but how do we do it in ASP 2.0? The examples
I see are setting up controls compeletly at design time.

Thanks,
Charlie

Apr 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1262
by: Shane O. Pinnell | last post by:
Does anyone know of a resource for information on how to create a working databound DDL in a datagrid using code behind? I have found a plethora of resources for doing this without code-behind, but I would prefer (and would like to understand how) to do it utilizing code-behind. Thanks! Shane
5
14113
by: clickon | last post by:
This is driving me nuts, it is such a simply thing to do but i cannot for the life of me work out how you are suposed to do it. I want to update the data in DropDownListB based on what is selected in DropDownListA. I am not trying to do anything fancy with AJAX, i am happy to use Post Backs. If it were two controls just on the page then i would simply specify a control parameter for the SelectCommand of the SQLDataSource control which...
3
5424
by: Jeff | last post by:
hey asp.net 2.0 I want to programmatically populate (with data from the database) a label control in a FormView on a webpage. Is it a good idea to put my logic inside the DataBound event of the FormView?
5
26634
by: nzkks | last post by:
Hi I am using these: ASP.Net 2.0, VB.Net, Visual Studio 2005, SQL Server 2005, Formview controls In a ASP.Net form I have 20 textboxes and 20 dropdownlists(ddl). All ddl(s) are databound and get the data from a single objectdatasource. All textboxes and ddl(s) support null values. Textboxes are for entering numbers and ddl(s) are for selecting the unit (mm, cm, in, m3, oz, qt like these.). I am using the below code to achieve two...
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9522
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10443
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10216
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10002
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5565
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.