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

Why visible=false only work sometimes on datagrid?

The following code in my onitemcreated works for some item rows in my
datagrid, but not others. I am trying to set a linkbutton visible for
downloading a file if the data is available in the database, otherwise
set a "not available" label visible. The outcome is that for the first
row on my datagrid, the linkbutton is visible, for the second row both
the linkbutton *and* the label are visible and for the third row, again
only the linkbutton is visible:

private void OnItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item)
{
if(DataBinder.Eval(e.Item.DataItem,"RESULT") == DBNull.Value)
((LinkButton)e.Item.Cells[10].FindControl("lbtnDownload")).Visible =
false;
else
((Label)e.Item.Cells[10].FindControl("lblNotAvailable")).Visible =
false;
}
}

Thanks in advance.

Adam Smith

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
3 2075
Your code is executing for all ListItemType.Item types ... you have to also
include the ListItemType.AlternatingItem type!

Thanks,
- jeff

"Adam Smith" <ad*********@hotmail.com> wrote in message
news:eS*************@tk2msftngp13.phx.gbl...
The following code in my onitemcreated works for some item rows in my
datagrid, but not others. I am trying to set a linkbutton visible for
downloading a file if the data is available in the database, otherwise
set a "not available" label visible. The outcome is that for the first
row on my datagrid, the linkbutton is visible, for the second row both
the linkbutton *and* the label are visible and for the third row, again
only the linkbutton is visible:

private void OnItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item)
{
if(DataBinder.Eval(e.Item.DataItem,"RESULT") == DBNull.Value)
((LinkButton)e.Item.Cells[10].FindControl("lbtnDownload")).Visible =
false;
else
((Label)e.Item.Cells[10].FindControl("lblNotAvailable")).Visible =
false;
}
}

Thanks in advance.

Adam Smith

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #2
Hello Adam,

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
private void OnItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{ if(e.Item.ItemType == ListItemType.Item)
{
if(DataBinder.Eval(e.Item.DataItem,"RESULT") == DBNull.Value)
((LinkButton)e.Item.Cells[10].FindControl("lbtnDownload")).Visible =
false;
else
((Label)e.Item.Cells[10].FindControl("lblNotAvailable")).Visible =
false;
}
}


--
Matt Berther
http://www.mattberther.com
Nov 18 '05 #3
Thanks!

Matt Berther <mb******@hotmail.com> wrote in message news:<OW**************@TK2MSFTNGP12.phx.gbl>...
Hello Adam,

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
private void OnItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{

if(e.Item.ItemType == ListItemType.Item)
{
if(DataBinder.Eval(e.Item.DataItem,"RESULT") == DBNull.Value)
((LinkButton)e.Item.Cells[10].FindControl("lbtnDownload")).Visible =
false;
else
((Label)e.Item.Cells[10].FindControl("lblNotAvailable")).Visible =
false;
}
}

Nov 18 '05 #4

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

Similar topics

0
by: awightma | last post by:
Hi, I have a datagrid with a number of textboxes on it. I want one column of my table to be visible=false because it contains the id of the record from the table. For some reason when I set...
1
by: Marc Lefebvre | last post by:
Why I was unable to hide the previous button in the following code ? private void ButtonClick(Object sender, System.EventArgs e) { Button button = (Button)sender; Button previousButton =...
3
by: Adam Smith | last post by:
The following code in my onitemcreated works for some item rows in my datagrid, but not others. I am trying to set a linkbutton visible for downloading a file if the data is available in the...
8
by: tshad | last post by:
I have a column in a list where I need to keep track of some data (but not show it) and am setting it as false. This works fine in IE, but Netscape and Mozilla show a little space where the column...
5
by: DraguVaso | last post by:
Hi, I have a MDIForm with some MDIChilds. When the user clicks on the "x" in the upper right corner, I don't want the MDIChild to be closed, but the property Visible = False. So far no...
4
by: Kelly Dykstra | last post by:
Hi I like to make certain tab visible or not visible based on a certain condition However, after executing the following statement, it still shows TabPages(2) ( this tabcontrol has 4 tapPages...
2
by: Kristof Taveirne | last post by:
Hi, I'm developing an application on PDA using WindowsCE. In my application I have several tabs at the bottom of my screen. However, in one of the tabs I've placed 2 radiobutton, used to switch...
1
by: walanta | last post by:
I'm trying to get rid of the TextBox1 and Button1 on the page after posted back. However, it's still visible. Any idea why? protected void Page_Load(object sender, EventArgs e) { if...
4
by: thecheyenne | last post by:
Hi there everybody; Fresh from reading my Access VBA for Dummies, I'd like to update my database about activities on a school outing. Here's what I'd like to achieve. The school outing costs...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.