473,608 Members | 2,410 Online
Bytes | Software Development & Data Engineering Community
+ 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:BoundColum n DataField="clnP opulationCensus "
SortExpression= "clnPopulationC ensus" HeaderText="Pop ulation (Census)"
DataFormatStrin g=""></asp:BoundColumn >

Would this go in the DataFormatStrin g column? Or somewhere else?

Here's my adapter:

'SqlDataAdapter 1
'
Me.SqlDataAdapt er1.SelectComma nd = Me.SqlSelectCom mand1
Me.SqlDataAdapt er1.TableMappin gs.AddRange(New
System.Data.Com mon.DataTableMa pping() {New
System.Data.Com mon.DataTableMa pping("Table", "sac1SelectSurv ey1", New
System.Data.Com mon.DataColumnM apping() {New
System.Data.Com mon.DataColumnM apping("clnGUID ", "clnGUID"), New
System.Data.Com mon.DataColumnM apping("clnPrio rityCorrectedTC ",
"clnPriorityCor rectedTC"), New
System.Data.Com mon.DataColumnM apping("clnMADo neTC", "clnMADoneT C"), New
System.Data.Com mon.DataColumnM apping("clnMASc hoolTC", "clnMASchoolTC" ), New
System.Data.Com mon.DataColumnM apping("clnMAPo sterTC", "clnMAPosterTC" ), New
System.Data.Com mon.DataColumnM apping("clnMARa dioTC", "clnMARadioTC") , New
System.Data.Com mon.DataColumnM apping("clnMAPe rformingGroupTC ",
"clnMAPerformin gGroupTC"), New
System.Data.Com mon.DataColumnM apping("clnMACo mmunityCenterTC ",
"clnMACommunity CenterTC"), New
System.Data.Com mon.DataColumnM apping("clnMARe ligiousOrganiza tionTC",
"clnMAReligious OrganizationTC" ), New
System.Data.Com mon.DataColumnM apping("clnMAOt herTC", "clnMAOtherTC") , New
System.Data.Com mon.DataColumnM apping("clnMAOt her", "clnMAOther "), New
System.Data.Com mon.DataColumnM apping("clnMAOr ganisation",
"clnMAOrganisat ion")}), New System.Data.Com mon.DataTableMa pping("Table1",
"Table1", New System.Data.Com mon.DataColumnM apping() {New
System.Data.Com mon.DataColumnM apping("clnGUID ", "clnGUID"), New
System.Data.Com mon.DataColumnM apping("clnName ", "clnName")} )})
--
_______________ ___________
Glenn Levine
gl*********@hot mail.com

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

"One never knows, does one?"
Nov 20 '05 #1
5 1730
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******@visio ntechnology.net > scripsit:
I have a simple datagrid and need to output the value of "0" (zero) if the
value is null.

<asp:BoundColum n DataField="clnP opulationCensus "
SortExpression= "clnPopulationC ensus" HeaderText="Pop ulation (Census)"
DataFormatStrin g=""></asp:BoundColumn >


Group for ASP.NET DataGrid:

<news://msnews.microsof t.com/microsoft.publi c.dotnet.framew ork.aspnet.data gridcontrol>

--
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******** ********@TK2MSF TNGP11.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.publi c.dotnet.framew ork.aspnet.data gridcontrol 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******** ********@TK2MSF TNGP11.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
2587
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 hyperlink. <asp:hyperlinkcolumn headertext="Question" SortExpression="QDescription" datatextfield="QDescription"
3
4670
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 appear only in rows when a condition is met and I'm not sure how to accomplish this. The default behaviour is to appear in every row on the datagrid.
1
2184
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 retrieve the value into a variable fine. My problem is that I have no idea what code to use to tell a button not to be displayed if I don't get a certain value. In ASP I would just embed VBScript to check the value of the variable in an if then and...
3
1774
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 tried using CSS but that doesn't affect what is going on in my datagrid. This is what I have so far for formatting in my datagrid... Sub ItemBound(ByVal sender As Object, ByVal e as DataGridItemEventArgs) If e.Item.ItemType = ListItemType.Item Or...
2
6389
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
1960
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, but the RescheduledFromDate does. In general, only a GigDate will be supplied, but if a Gig is rescheduled, the GigDate is copied to RescheduledFromDate, and the GigDate then becomes the "new" date. I'm using a DataList instead of a Grid because...
0
786
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 1 is editable else same row, column 1 is read only end if
4
2502
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 TextBox to display its value when you leave the TextBox. I figure that I need to use the SetColumnValueAtRow Method but I am struggling to understand how.
1
4573
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 conditional formatting on the gridview but it doesnt have the same methods. Currently in my datagrid I have this (this is just hacked together randomly but gives you the idea):
0
8501
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
8483
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...
1
8157
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6820
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5479
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4030
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2477
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
1
1607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1336
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.