473,513 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

my first datagrid custom column - feedback appreciated!

i have just developed my first datagrid custom column. it is very
simple. i know that each cell will only display a char value of 'T'
or 'F'. so if the cell value is 'T' i am displaying a ticked checkbox
image and if it is 'F' i am displaying a blank checkbox image.

it seems to be working ok but as this is my first attempt I am posting
my code as I do not know if I have coded it the best way. many thanks
for any feedback.

public class CheckboxColumn : BoundColumn
{
public CheckboxColumn(): base()
{
}

public override void InitializeCell(TableCell cell, int
columnIndex, ListItemType itemType)
{
base.InitializeCell(cell, columnIndex, itemType);
if (itemType == ListItemType.Item || itemType ==
ListItemType.AlternatingItem)
cell.DataBinding += new
EventHandler(OnDataBinding);
}

private void OnDataBinding(object sender, EventArgs e)
{
HtmlImage hi = new HtmlImage();
if (((TableCell) sender).Text ==
"T")
hi.Src = "../images/checkbox_ticked.gif";
else
hi.Src = "../images/checkbox_blank.gif";
((TableCell)
sender).Controls.Add(hi);
}
}
[/code]

Nov 18 '05 #1
0 1225

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

Similar topics

1
1977
by: CGuy | last post by:
Hi, I have a datagrid that supports bi-directional sorting - i would like an icon (like an up or down arrow depending on the sort order) to be displayed in the datagrid column headers which...
1
1208
by: pcPirate | last post by:
Hi, In C# i) Is there anyway to input value on particular cell in datagrid in the coding? ii) How do I save the contents of the datagrid back to database? iii) I've made a custom...
2
2479
by: Bill C. | last post by:
Hi, I'm trying to implement a ComboBox drop-down column for a DataGrid. When a cell is selected in the ComboBox column I overlay a ComboBox over the cell and call: this.comboBox.Show();...
1
1624
by: Vagabond Software | last post by:
I am creating a custom datagrid based, in part, from someone else's code. The author declared a derived datagrid class in a windows form, then declared a derived ColumnStyle class, in the same form,...
0
1811
by: Frnak McKenney | last post by:
One of the reasons given for the Allied victory in WWI is that the Nazi armament industry invested so much effort in creating new weapons (e.g. the jet plane) it wasn't able to develop any of them...
5
12209
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. ...
1
2215
by: Conawapa11 | last post by:
I'm having trouble figuring this problem out and every example out there deals with simple objects within a custom collection. Take this example: public class ComplexClass { private int id;...
5
4557
by: cwbp17 | last post by:
Hi all, Have a datagrid that displays the price column of a table. Went to the Datagrid's Property builder and set the 'Data Formatting expression' for the PRICE column to {0:c}, so that the...
1
4214
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
0
7257
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
7535
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...
1
7098
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...
0
4745
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...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1591
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 ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
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...

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.