473,327 Members | 2,071 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,327 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 2072
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.