473,398 Members | 2,380 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,398 software developers and data experts.

Suppress data from displaying in the cell in datagrid

Hello, everyone.

Is there a way to not display a certain value in a datagrid cell?

I have a datagrid for subscriptions and ebooks and if there isn't an e-book
listed, the value from the database (SQL) is "Null/No Set Dummy Row".

Is there a way I can suppress that data in the datagrid?

Thanks,
Antonio
Jun 30 '06 #1
5 3142
Antonio,
the ItemDataBound event fires as each row of your DataGrid is bound. You can
gain access to each cell, its contents (including any controls within the
cell) in this eventhandler and make any modifications you want. See MSDN
documentation for syntax and code examples.
Peter

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


"Antonio" wrote:
Hello, everyone.

Is there a way to not display a certain value in a datagrid cell?

I have a datagrid for subscriptions and ebooks and if there isn't an e-book
listed, the value from the database (SQL) is "Null/No Set Dummy Row".

Is there a way I can suppress that data in the datagrid?

Thanks,
Antonio

Jun 30 '06 #2
Hi, Peter,

Thanks for replying.

I have this code in the Item_Bound method and I get a "Cannot implicitly
convert type 'string' to 'bool'

if (e.Item.Cells[4].Text = "Null/No Set Dummy Row")

e.Item.Cells[4].Text = "None";

Am I missing something?

Thank,

Antonio

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:88**********************************@microsof t.com...
Antonio,
the ItemDataBound event fires as each row of your DataGrid is bound. You
can
gain access to each cell, its contents (including any controls within the
cell) in this eventhandler and make any modifications you want. See MSDN
documentation for syntax and code examples.
Peter

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


"Antonio" wrote:
Hello, everyone.

Is there a way to not display a certain value in a datagrid cell?

I have a datagrid for subscriptions and ebooks and if there isn't an
e-book
listed, the value from the database (SQL) is "Null/No Set Dummy Row".

Is there a way I can suppress that data in the datagrid?

Thanks,
Antonio

Jun 30 '06 #3
Antonio,
Whenever you see this exception you must remember to ask yourself,
"Should I be using one equals sign or two?".

if (e.Item.Cells[4].Text = "Null/No Set Dummy Row")

-- the above is not a test for equality. It is an attempt to ASSIGN
"Nul...." to the .Text property within an if( ... ) statement. I think you
want a test for equality
"==" here.
Peter

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


"Antonio" wrote:
Hi, Peter,

Thanks for replying.

I have this code in the Item_Bound method and I get a "Cannot implicitly
convert type 'string' to 'bool'

if (e.Item.Cells[4].Text = "Null/No Set Dummy Row")

e.Item.Cells[4].Text = "None";

Am I missing something?

Thank,

Antonio

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:88**********************************@microsof t.com...
Antonio,
the ItemDataBound event fires as each row of your DataGrid is bound. You
can
gain access to each cell, its contents (including any controls within the
cell) in this eventhandler and make any modifications you want. See MSDN
documentation for syntax and code examples.
Peter

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


"Antonio" wrote:
Hello, everyone.

Is there a way to not display a certain value in a datagrid cell?

I have a datagrid for subscriptions and ebooks and if there isn't an
e-book
listed, the value from the database (SQL) is "Null/No Set Dummy Row".

Is there a way I can suppress that data in the datagrid?

Thanks,
Antonio


Jun 30 '06 #4
Thank you, Peter, that gets me sometimes...

Now I am getting a
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: CS0122: 'SalesApp.subscriptions.Item_Bound(object,
System.Web.UI.WebControls.DataGridItemEventArgs)' is inaccessible due to its
protection level

and the highlighted line is line 14

Source Error:

Line 12: <form id="Form1" method="post" runat="server">
Line 13: <IMG style="Z-INDEX: 100; LEFT: 8px; POSITION: absolute; TOP:
8px" src="Images/logo.gif">
Line 14: <asp:DataGrid id="dgSubs" style="Z-INDEX: 102; LEFT: 24px;
POSITION: absolute; TOP: 128px" runat="server" OnItemDataBound="Item_Bound"
Line 15: BorderColor="#CCCCCC" BorderStyle="Ridge" BorderWidth="1px"
BackColor="White" CellPadding="0"
Line 16: AllowPaging="True" Font-Size="Smaller" CellSpacing="2"
Width="1000px" HorizontalAlign="Center">

"Peter Bromberg [C# MVP]" wrote:
Antonio,
Whenever you see this exception you must remember to ask yourself,
"Should I be using one equals sign or two?".

if (e.Item.Cells[4].Text = "Null/No Set Dummy Row")

-- the above is not a test for equality. It is an attempt to ASSIGN
"Nul...." to the .Text property within an if( ... ) statement. I think you
want a test for equality
"==" here.
Peter

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


"Antonio" wrote:
Hi, Peter,

Thanks for replying.

I have this code in the Item_Bound method and I get a "Cannot implicitly
convert type 'string' to 'bool'

if (e.Item.Cells[4].Text = "Null/No Set Dummy Row")

e.Item.Cells[4].Text = "None";

Am I missing something?

Thank,

Antonio

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:88**********************************@microsof t.com...
Antonio,
the ItemDataBound event fires as each row of your DataGrid is bound. You
can
gain access to each cell, its contents (including any controls within the
cell) in this eventhandler and make any modifications you want. See MSDN
documentation for syntax and code examples.
Peter

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


"Antonio" wrote:

> Hello, everyone.
>
> Is there a way to not display a certain value in a datagrid cell?
>
> I have a datagrid for subscriptions and ebooks and if there isn't an
> e-book
> listed, the value from the database (SQL) is "Null/No Set Dummy Row".
>
> Is there a way I can suppress that data in the datagrid?
>
> Thanks,
>
>
> Antonio
>
>


Jun 30 '06 #5
Ok, Peter,
I set the Item_Bound in the Page_Load event
private void Page_Load(object sender, System.EventArgs e)
{
dgSubs.ItemDataBound += new DataGridItemEventHandler(this.Item_Bound);
bindGrid();
}

The Item_Bound event is

private void Item_Bound(Object sender, DataGridItemEventArgs e)

{
if (e.Item.Cells[4].Text == "Null/No Set Dummy Row")

e.Item.Cells[4].Text = "None";
}

and it never gets to the e.Item.Cells[4].Text = "None"; line, so, it still
displays the "Null/No Set Dummy Row"

"Antonio" <An*****@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com...
Thank you, Peter, that gets me sometimes...

Now I am getting a
Compilation Error
Description: An error occurred during the compilation of a resource
required
to service this request. Please review the following specific error
details
and modify your source code appropriately.

Compiler Error Message: CS0122: 'SalesApp.subscriptions.Item_Bound(object,
System.Web.UI.WebControls.DataGridItemEventArgs)' is inaccessible due to
its
protection level

and the highlighted line is line 14

Source Error:

Line 12: <form id="Form1" method="post" runat="server">
Line 13: <IMG style="Z-INDEX: 100; LEFT: 8px; POSITION: absolute; TOP:
8px" src="Images/logo.gif">
Line 14: <asp:DataGrid id="dgSubs" style="Z-INDEX: 102; LEFT: 24px;
POSITION: absolute; TOP: 128px" runat="server"
OnItemDataBound="Item_Bound"
Line 15: BorderColor="#CCCCCC" BorderStyle="Ridge" BorderWidth="1px"
BackColor="White" CellPadding="0"
Line 16: AllowPaging="True" Font-Size="Smaller" CellSpacing="2"
Width="1000px" HorizontalAlign="Center">

"Peter Bromberg [C# MVP]" wrote:
Antonio,
Whenever you see this exception you must remember to ask yourself,
"Should I be using one equals sign or two?".

if (e.Item.Cells[4].Text = "Null/No Set Dummy Row")

-- the above is not a test for equality. It is an attempt to ASSIGN
"Nul...." to the .Text property within an if( ... ) statement. I think
you
want a test for equality
"==" here.
Peter

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


"Antonio" wrote:
> Hi, Peter,
>
> Thanks for replying.
>
> I have this code in the Item_Bound method and I get a "Cannot
> implicitly
> convert type 'string' to 'bool'
>
> if (e.Item.Cells[4].Text = "Null/No Set Dummy Row")
>
> e.Item.Cells[4].Text = "None";
>
> Am I missing something?
>
> Thank,
>
> Antonio
>
> "Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in
> message
> news:88**********************************@microsof t.com...
> > Antonio,
> > the ItemDataBound event fires as each row of your DataGrid is bound.
> > You
> > can
> > gain access to each cell, its contents (including any controls within
> > the
> > cell) in this eventhandler and make any modifications you want. See
> > MSDN
> > documentation for syntax and code examples.
> > Peter
> >
> > --
> > Co-founder, Eggheadcafe.com developer portal:
> > http://www.eggheadcafe.com
> > UnBlog:
> > http://petesbloggerama.blogspot.com
> >
> >
> >
> >
> > "Antonio" wrote:
> >
> >> Hello, everyone.
> >>
> >> Is there a way to not display a certain value in a datagrid cell?
> >>
> >> I have a datagrid for subscriptions and ebooks and if there isn't an
> >> e-book
> >> listed, the value from the database (SQL) is "Null/No Set Dummy
> >> Row".
> >>
> >> Is there a way I can suppress that data in the datagrid?
> >>
> >> Thanks,
> >>
> >>
> >> Antonio
> >>
> >>
>
>
>

Jun 30 '06 #6

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

Similar topics

2
by: Stephen | last post by:
I'm trying to work with a datagrid column in order to display a tooltip in a datagrid cell. The reason I am doing this is because I have some long strings being returned and I don't want the rows...
1
by: sups sups via .NET 247 | last post by:
Hi.. I have two tables one called State and the other called City. State City State_ID City_ID State_Name City_Nm State_ID and so on.. I have created 2 datagrids.
1
by: Ananth | last post by:
Hi, I have a question regarding data grids My application requires me to use a grid for displaying data, however I would not be using a database for procuring the data, instead I would be...
2
by: sunstarwu | last post by:
Hi, I am having difficultly being able to view certain Columns and rows via a DropDownList. Everytime I load my webpage.aspx it just shows empty drop down menus. I have no problem showing all...
2
by: Nedu N | last post by:
Hi, I want to display the XML tags (for the the XML tags is the data that is stored in a table) on the datagrid using the datasets. But since the data itself is the XML tag it doesn't appera on...
2
by: John Hoge | last post by:
I have a datagrid displaying a number of narrow columns and one very wide one. It would make sense from a layout perspective to have two rows per dataitem, and to put the long descriptive field...
9
by: Sean | last post by:
I am using a datagrid to display some data. I notice when I click in a cell where the data is longer than the cell width, it truncates the end of the data off. For example: The data is: This...
1
by: adi busu via DotNetMonster.com | last post by:
Hi I need an event that could help me to update the datagrid current cell data every time it is changed. i tried with currentCellChanged but when i leave the datagrid this event does not occure...
6
by: insirawali | last post by:
Hi all, I have this problem, i need to know is there a way i cn use the data adapter's update method in this scenario. i have 3 tables as below create table table1{ id1 int identity(1,1)...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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.