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 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
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
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
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 > >
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 > >> > >> > > > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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.
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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)...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |