473,396 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how-to add checkboxfield dynamically to gridview control

I have a gridview declaratively added to my webform. This gridview
displays data from a stored procedure returned as a dataset. Once the
dataset has been modified slightly i bind it to my gridview control.
Now where and how would i go about adding a column to my gridview
dynamically that is a checkboxfield and is checked based on some
criteria i want to use. An example...

if
DataSet.Tables(0).Rows(i).Item("Discontinued").toS tring().Equals("yes")
then
checkboxfield is readonly and checked when displayed
next row from dataset

Here is my <Columnssection of my gridview control

<Columns>
<asp:BoundField
DataField="customerNumber" HeaderText="CustomerNumber" />
<asp:BoundField
DataField="address2" HeaderText="Attention" />
<asp:BoundField DataField="city"
HeaderText="City" />
<asp:BoundField DataField="state"
HeaderText="State" />
<asp:BoundField DataField="zipcode"
HeaderText="Zipcode" />
<asp:BoundField
DataField="distance" HeaderText="Distance" />
<asp:HyperLinkField Text="Customer
Info.." DataNavigateUrlFields="rowid" Target="_blank"
DataNavigateUrlFormatString="Products.aspx?id={0}" />
</Columns>

Thanks for any help regarding this in advance

Kyle Spitzer

Nov 10 '06 #1
1 4728

"spitapps" <ky**********@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
>I have a gridview declaratively added to my webform. This gridview
displays data from a stored procedure returned as a dataset. Once the
dataset has been modified slightly i bind it to my gridview control.
Now where and how would i go about adding a column to my gridview
dynamically that is a checkboxfield and is checked based on some
criteria i want to use. An example...
In a similar situation I set up an empty panel as the only object in a
column template. At bind time I then looped thru the a variable (in the db)
that told me how many images to add to the panel. eg:
Panel thisPanel = (Panel)e.Row.FindControl("Panel4Spectrums");
for(i= etc
HtmlImage thisSpectrum = new (HtmlImage());
thisSpectrum.add ...etc..
thisSpectrum.Attributes.Add("onclick","return ...etc
thisPanel.Controls.Add(thisSpectrum)

You can also add a column and later drop it as in "ALTER table ADD COLUMN
"NewCo.lumnName" You can set up the column and make it invisible until you
want to show it

...hth..
--
================================================== =====================
Beemer Biker joestateson at grandecom dot net
http://TipsForTheComputingImpaired.com
http://ResearchRiders.org Ask about my 99'R1100RT
================================================== =====================

if
DataSet.Tables(0).Rows(i).Item("Discontinued").toS tring().Equals("yes")
then
checkboxfield is readonly and checked when displayed
next row from dataset

Here is my <Columnssection of my gridview control

<Columns>
<asp:BoundField
DataField="customerNumber" HeaderText="CustomerNumber" />
<asp:BoundField
DataField="address2" HeaderText="Attention" />
<asp:BoundField DataField="city"
HeaderText="City" />
<asp:BoundField DataField="state"
HeaderText="State" />
<asp:BoundField DataField="zipcode"
HeaderText="Zipcode" />
<asp:BoundField
DataField="distance" HeaderText="Distance" />
<asp:HyperLinkField Text="Customer
Info.." DataNavigateUrlFields="rowid" Target="_blank"
DataNavigateUrlFormatString="Products.aspx?id={0}" />
</Columns>

Thanks for any help regarding this in advance

Kyle Spitzer

Nov 10 '06 #2

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

Similar topics

4
by: Tom Szabo | last post by:
Just wandering how can you close a browser remotely. In some web applications the browser closes or refreshes periodically. How is that done and how can it be done through PHP? TIA, Tom
0
by: v I n O | last post by:
hI Geeks Please do let me know how do i find how many instances sql server running on the single machine. or in the n/w my objective should with help of C#/vb.net
4
by: James Salisbury | last post by:
Hi, I was checking my parent's website salisbury.cabrera.net on google by entering villa rent spain cabrera I can see the required site, ranked at 4, but I am concerend by the return at 1 and 5...
2
by: Frances Del Rio | last post by:
http://www.emol.com/especiales/cocina_chilena/comida.asp this page is so neat (goes in pop-up..) how was this done? how do you give a layer (or div, I guess) a semi-transparency so you can still...
4
by: | last post by:
Developing, building, and testing. How do it the best? Learning from the world leader - Microsoft I'm very interested in how the developing/build/testing workflow @ Microsoft looks like. I...
4
by: Supra | last post by:
in vb6 listbox1.remove item 5 how will i do in vb.net? regards
3
by: dba2adm | last post by:
The SNAPSHOT_STATEMENT table function gives the CPU used rows read etc information. How do I know the total number of time the particular statement was executed (as in snapshot_dyn_sql's...
7
by: anushhprabu | last post by:
#define q(k)main(){ return!puts(#k"\nPRABUq("#k")");} q(#define q(k)main(){return!puts(#k"\nq("#k")");}) guys i'm working on this code.. i got it fromnet.. how this is working.. anyone pls.....
0
by: candra | last post by:
Learn What Hackers Know? -General Hacking Information -Password Security -Scanning, Fingerprinting And Similar Techniques -How Hackers Attack Numerous Internet Services -How Hackers Attack Web...
2
by: belred | last post by:
i just read this blog about how many objects (types) are loaded for a hello world program in C#. http://blogs.msdn.com/abhinaba/archive/2008/09/15/how-many-types-are-loaded-for-hello-world.aspx ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.