473,668 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3210
How about this?

MyDatagrid.Colu mns[0].Visible = false;

"CGuy" <cg**@csharp.ne t> wrote in message
news:OJ******** ******@TK2MSFTN GP09.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.Colu mns[0].Visible = false;

"CGuy" <cg**@csharp.ne t> wrote in message
news:OJ******** ******@TK2MSFTN GP09.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_ItemDa taBound(object sender, DataGridItemEve ntArgs e)
{
if(e.Item.ItemT ype == ListItemType.It em || e.Item.ItemType ==
ListItemType.Al ternatingItem)
{
if(!ControlStat us)
{
//If ControlStatus is False, remove the LinkButton and Add a
Label
e.Item.Cells[1].Controls.Remov eAt(0);
Label labelItem = new Label();
labelItem.Text = "Text";
e.Item.Cells[1].Controls.Add(l abelItem);
}
}
}
"Rajesh.V" <Ra***********@ hotmail.com> wrote in message
news:OH******** *****@TK2MSFTNG P10.phx.gbl...
How about this?

MyDatagrid.Colu mns[0].Visible = false;

"CGuy" <cg**@csharp.ne t> wrote in message
news:OJ******** ******@TK2MSFTN GP09.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_ItemDa taBound(object sender, DataGridItemEve ntArgs e)
{
if(e.Item.ItemT ype == ListItemType.It em || e.Item.ItemType ==
ListItemType.Al ternatingItem)
{
if(!ControlStat us)
{
//If ControlStatus is False, remove the LinkButton and Add a
Label
e.Item.Cells[1].Controls.Remov eAt(0);
Label labelItem = new Label();
labelItem.Text = "Text";
e.Item.Cells[1].Controls.Add(l abelItem);
}
}
}
"Rajesh.V" <Ra***********@ hotmail.com> wrote in message
news:OH******** *****@TK2MSFTNG P10.phx.gbl...
How about this?

MyDatagrid.Colu mns[0].Visible = false;

"CGuy" <cg**@csharp.ne t> wrote in message
news:OJ******** ******@TK2MSFTN GP09.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
276
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 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.
1
4314
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 (watch the layout, some have child controls):
2
2027
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 level. Is this expected? Shouldn't anything on the properties window render accordingly? Thanks
1
3396
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 event when the user clicks the button column here is my html for the datagrid ************************************************************************************** <Columns> <asp:HyperLinkColumn Target="_blank" DataNavigateUrlField="Title"...
5
1223
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... <HyperLinkColumn><ButtonColumn><ButtonColumn><Data><Data> Can anyone help?
2
10039
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. <asp:ButtonColumn HeaderText="" ButtonType="LinkButton" Text="Edit" CommandName="EditRec">
5
6546
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
1406
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 an invoice has been processed I do not want a button to display for this invoice but all other unprocessed invoices need the button to be displayed. Any ideas?
2
1458
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 DataGrid that gets populated dynamically from data within a MSSQL database. To keep this short lets just say that the DataGrid gets populated with five rows from the database. There is a “ButtonColumn” within the DataGrid that has the property...
0
8459
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8374
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8890
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8791
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8575
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8653
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5677
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2784
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1783
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.