473,480 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

conditional in datagrid column

I have a simple datagrid and need to output the value of "0" (zero) if the
value is null.

<asp:BoundColumn DataField="clnPopulationCensus"
SortExpression="clnPopulationCensus" HeaderText="Population (Census)"
DataFormatString=""></asp:BoundColumn>

Would this go in the DataFormatString column? Or somewhere else?

Here's my adapter:

'SqlDataAdapter1
'
Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1
Me.SqlDataAdapter1.TableMappings.AddRange(New
System.Data.Common.DataTableMapping() {New
System.Data.Common.DataTableMapping("Table", "sac1SelectSurvey1", New
System.Data.Common.DataColumnMapping() {New
System.Data.Common.DataColumnMapping("clnGUID", "clnGUID"), New
System.Data.Common.DataColumnMapping("clnPriorityC orrectedTC",
"clnPriorityCorrectedTC"), New
System.Data.Common.DataColumnMapping("clnMADoneTC" , "clnMADoneTC"), New
System.Data.Common.DataColumnMapping("clnMASchoolT C", "clnMASchoolTC"), New
System.Data.Common.DataColumnMapping("clnMAPosterT C", "clnMAPosterTC"), New
System.Data.Common.DataColumnMapping("clnMARadioTC ", "clnMARadioTC"), New
System.Data.Common.DataColumnMapping("clnMAPerform ingGroupTC",
"clnMAPerformingGroupTC"), New
System.Data.Common.DataColumnMapping("clnMACommuni tyCenterTC",
"clnMACommunityCenterTC"), New
System.Data.Common.DataColumnMapping("clnMAReligio usOrganizationTC",
"clnMAReligiousOrganizationTC"), New
System.Data.Common.DataColumnMapping("clnMAOtherTC ", "clnMAOtherTC"), New
System.Data.Common.DataColumnMapping("clnMAOther", "clnMAOther"), New
System.Data.Common.DataColumnMapping("clnMAOrganis ation",
"clnMAOrganisation")}), New System.Data.Common.DataTableMapping("Table1",
"Table1", New System.Data.Common.DataColumnMapping() {New
System.Data.Common.DataColumnMapping("clnGUID", "clnGUID"), New
System.Data.Common.DataColumnMapping("clnName", "clnName")})})
--
__________________________
Glenn Levine
gl*********@hotmail.com

Cell: (202) 374-4871
Home: (703) 212-6723

"One never knows, does one?"
Nov 20 '05 #1
5 1717
Cor
Hi DC Gringo,

I cannot see if you did use the designer from VS.net and did drag things to
your form, but when you want to put a datatable from a database in a
datagrid you need minimal the folowing

a connection with your database (SqlConnection)
a dataset
a SqlDataAdapter
a Datagrid

The dataset can be bounded using the datasourse to the datagrid.

To see a lot of examples for that try to use this.

http://msdn.microsoft.com/vbasic/vbrkit/default.aspx

And if you have problems installing it

http://msdn.microsoft.com/vbasic/vbr...q/#installvdir

I hope this helps a little bit?

Cor
Nov 20 '05 #2
* "DC Gringo" <dc******@visiontechnology.net> scripsit:
I have a simple datagrid and need to output the value of "0" (zero) if the
value is null.

<asp:BoundColumn DataField="clnPopulationCensus"
SortExpression="clnPopulationCensus" HeaderText="Population (Census)"
DataFormatString=""></asp:BoundColumn>


Group for ASP.NET DataGrid:

<news://msnews.microsoft.com/microsoft.public.dotnet.framework.aspnet.datagridc ontrol>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
Cor,

Yes, of course, all of that is in place and my datagrid is showing. I did
use the VS.NET designer as you described. What I'm looking for help on is
how to alter data values based on conditional processing within this
framework.

In particular, if a data value is null, I want to show a zero or a "none"
value.

_____
Glenn

I'm just looking to deal with the output.
"Cor" <no*@non.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi DC Gringo,

I cannot see if you did use the designer from VS.net and did drag things to your form, but when you want to put a datatable from a database in a
datagrid you need minimal the folowing

a connection with your database (SqlConnection)
a dataset
a SqlDataAdapter
a Datagrid

The dataset can be bounded using the datasourse to the datagrid.

To see a lot of examples for that try to use this.

http://msdn.microsoft.com/vbasic/vbrkit/default.aspx

And if you have problems installing it

http://msdn.microsoft.com/vbasic/vbr...q/#installvdir

I hope this helps a little bit?

Cor

Nov 20 '05 #4
Cor
Hi DC,

I am not that deep in the datagrid webcontrol that I know if there are easy
posibilities for your last question. But you can ask this also in the

Microsoft.public.dotnet.framework.aspnet.datagridc ontrol newsgroup.

However because you did all with the designer I think you are limited and
for this kind of things you mostly have to go deep in the code.

databinding events can maybe do something for you. But for that you have to
go really deep in handmade code.

An alternative is adding extra colomns to your datasource but that needs
good knowledge from datatables.

However better is if you ask your question as simple as you ask did in your
last message in the newsgroup I did tell you above.

But do not forget to tell that you did make everything using the designer,
otherwise you get scripting answers or very deep hand made answers.

Sorry no solution in this answer.

Cor



Yes, of course, all of that is in place and my datagrid is showing. I did
use the VS.NET designer as you described. What I'm looking for help on is
how to alter data values based on conditional processing within this
framework.

In particular, if a data value is null, I want to show a zero or a "none"
value.

_____
Glenn

I'm just looking to deal with the output.
"Cor" <no*@non.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi DC Gringo,

I cannot see if you did use the designer from VS.net and did drag things

to
your form, but when you want to put a datatable from a database in a
datagrid you need minimal the folowing

a connection with your database (SqlConnection)
a dataset
a SqlDataAdapter
a Datagrid

The dataset can be bounded using the datasourse to the datagrid.

To see a lot of examples for that try to use this.

http://msdn.microsoft.com/vbasic/vbrkit/default.aspx

And if you have problems installing it

http://msdn.microsoft.com/vbasic/vbr...q/#installvdir

I hope this helps a little bit?

Cor


Nov 20 '05 #5
When I try to change the header text after Databind for a column I am getting the following error:
dgTest.Columns(0).HeaderText = "TEST#"

Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

PS: I am using .Net 2002 with servicepack2
Nov 20 '05 #6

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

Similar topics

3
2577
by: Kumar | last post by:
Hi Folks, I have a question regarding conditional hyperlink in datagrid. I want to display Hyperlink if my QID values in (1,4,5,6) other wise i want to display just Qdescription with out...
3
4663
by: JC | last post by:
Hi, I am using a Datagrid and populating it from a database. I have a 'delete' button column, and when click it executes the DeleteCommand event. My problem is I would like this button to...
1
2172
by: Tom Wells | last post by:
I have a few things such as buttons and URLs that may or may not be shown based on the value of a database column. I can hook to the database and get the dataset and datarecord just fine. I can...
3
1766
by: chuckdfoster | last post by:
I have a hyperlink column in my datagrid. I want my hyperlink to be green or red (depending on in/out status) no matter if the link has been visited or not. How can I accomplish this? I have...
2
6369
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
3
1949
by: Danny Tuppeny | last post by:
Hi all, I've got a DataList that's bound to a datasource with two columns (well, two that matter). One is called GigDate, and one is called RescheduledFromDate. GigDate doesn't allow NULLs,...
0
778
by: Rob Oldfield | last post by:
Anyone have any idea about what the best way is to make cells in a particular column of a datagrid read only if another condition is met? i.e. if value in column 0 = "whatever" same row, column...
4
2482
by: Doug Bell | last post by:
Hi, I needed to make a TextBox on a DataGrid ReadOnly based on the condition of another cell on its row. I achieved this using a Custom Data Column Class "DacDGTextColLotNo" but I can't get the...
1
4559
by: euan | last post by:
HI Guys, I have bee using conditional formatting in the datagrid recently and I am moving over to framework 2.0 and noticed the datagrid has been replaced by the gridview. So, I would like to do...
0
6920
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
7059
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,...
0
7103
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
7010
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...
0
5362
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,...
1
4799
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...
0
3011
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...
1
572
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
203
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.