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

Enabling/Disabling a DataGrid ButtonColumn

Hi,

I have a datagrid that has one ButtonColumn which is bound to a database
field.

My requirement is that when the page containing the datagrid is loaded,
I would like the ButtonColumn to be enabled/disabled based on the value of a
boolean variable that is calculated at runtime - if the value if false, I
don't want the ButtonColumn to display links for the displayed items.

Please help me in doing this.

CGuy
Nov 17 '05 #1
4 3182
How about this?

MyDatagrid.Columns[0].Visible = false;

"CGuy" <cg**@csharp.net> wrote in message
news:OJ**************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a datagrid that has one ButtonColumn which is bound to a database field.

My requirement is that when the page containing the datagrid is loaded, I would like the ButtonColumn to be enabled/disabled based on the value of a boolean variable that is calculated at runtime - if the value if false, I
don't want the ButtonColumn to display links for the displayed items.

Please help me in doing this.

CGuy

Nov 17 '05 #2
How about this?

MyDatagrid.Columns[0].Visible = false;

"CGuy" <cg**@csharp.net> wrote in message
news:OJ**************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a datagrid that has one ButtonColumn which is bound to a database field.

My requirement is that when the page containing the datagrid is loaded, I would like the ButtonColumn to be enabled/disabled based on the value of a boolean variable that is calculated at runtime - if the value if false, I
don't want the ButtonColumn to display links for the displayed items.

Please help me in doing this.

CGuy

Nov 17 '05 #3
Nope... that would make the whole column vanish!!!

My requirement is that based on a variable's value, the column should behave
like a ButtonColumn or a Bound Colummn.

I was able to find a solution myself. This is how I'm doing it.

private void DataGrid_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
if(!ControlStatus)
{
//If ControlStatus is False, remove the LinkButton and Add a
Label
e.Item.Cells[1].Controls.RemoveAt(0);
Label labelItem = new Label();
labelItem.Text = "Text";
e.Item.Cells[1].Controls.Add(labelItem);
}
}
}
"Rajesh.V" <Ra***********@hotmail.com> wrote in message
news:OH*************@TK2MSFTNGP10.phx.gbl...
How about this?

MyDatagrid.Columns[0].Visible = false;

"CGuy" <cg**@csharp.net> wrote in message
news:OJ**************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a datagrid that has one ButtonColumn which is bound to a database
field.

My requirement is that when the page containing the datagrid is

loaded,
I would like the ButtonColumn to be enabled/disabled based on the value of a
boolean variable that is calculated at runtime - if the value if false,

I don't want the ButtonColumn to display links for the displayed items.

Please help me in doing this.

CGuy


Nov 17 '05 #4
Nope... that would make the whole column vanish!!!

My requirement is that based on a variable's value, the column should behave
like a ButtonColumn or a Bound Colummn.

I was able to find a solution myself. This is how I'm doing it.

private void DataGrid_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
if(!ControlStatus)
{
//If ControlStatus is False, remove the LinkButton and Add a
Label
e.Item.Cells[1].Controls.RemoveAt(0);
Label labelItem = new Label();
labelItem.Text = "Text";
e.Item.Cells[1].Controls.Add(labelItem);
}
}
}
"Rajesh.V" <Ra***********@hotmail.com> wrote in message
news:OH*************@TK2MSFTNGP10.phx.gbl...
How about this?

MyDatagrid.Columns[0].Visible = false;

"CGuy" <cg**@csharp.net> wrote in message
news:OJ**************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a datagrid that has one ButtonColumn which is bound to a database
field.

My requirement is that when the page containing the datagrid is

loaded,
I would like the ButtonColumn to be enabled/disabled based on the value of a
boolean variable that is calculated at runtime - if the value if false,

I don't want the ButtonColumn to display links for the displayed items.

Please help me in doing this.

CGuy


Nov 17 '05 #5

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

Similar topics

0
by: CGuy | last post by:
Hi, I have a datagrid that has one ButtonColumn which is bound to a database field. My requirement is that when the page containing the datagrid is loaded, I would like the ButtonColumn to be...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
2
by: Marty McDonald | last post by:
When setting certain datagrid properties with the IDE (as in the property window), they don't seem to take effect. For instance, Font Name. So I have to set these via code-behind at the cell...
1
by: Lenin Sakthees via .NET 247 | last post by:
Hi all, I am using a datagrid to show values from a SQL table. My problem is, I want to show the details of the each row when the user clicks the 'View details' buttoncolumn. I am able to fire a...
5
by: Alan Seunarayan | last post by:
Hello, I need to create a DataGrid that looks something like this... <HyperLinkColumn><ButtonColumn><Data><Data><ButtonColumn> but I can only seem to produce a DataGrid as below... ...
2
by: pradeep_TP | last post by:
Hello world, I have a simple datagrid on asp.net web form , in which I am showing a single button column called EDIT. The code in the .aspx files for the same is as below. ...
5
by: Vik | last post by:
If there are a few Select buttons in a datagrid, is there a way to distinguish in code which button was clicked? Thanks.
2
by: Ray Booysen | last post by:
Hi all I have a collection of Invoices that I bind to a datagrid. Some of these invoices have been processed and you can tell this via a property in the invoice class called DateProcessed. If...
2
CroCrew
by: CroCrew | last post by:
Hello all, First off I would like to thank anyone that helps me out with this problem that I have. Ok, the environment I am working in is ASP.net with the code behind done in VB. I have a...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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...
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)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.