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

Datagrid query

Hi,

I have a datagrid being populated using an sqldatareader. One of the
columns returns a bit value which currently gets displayed as 'True' or
'False'.

I would like to be able to display an image of a tick when this value is
true, and have placed an asp.net image control within the relevant template
column. I presume I can achieve this within the databinding event of the
grid, but am unsure as to quite how!

I would be grateful if anyone could shed some light on this!

Many thanks, Carl
ca**********@m-s-solutions.co.uk
Nov 17 '05 #1
2 2909
In the .aspx file you could set the Image's Visible property to the
databound value, something like this:

<asp:Image Visible="<%# CBool(DataBinder.Eval(Container,
"DataItem.showTickGraphic") %>"> </asp:Image>

If this will acheive what you're looking for, it's a little less complex
than diving into the databinding events.

Hope that's useful,

--Jon

"Carl Howarth" <ca**********@m-s-solutions.co.uk> wrote in message
news:#q**************@TK2MSFTNGP11.phx.gbl...
Hi,

I have a datagrid being populated using an sqldatareader. One of the
columns returns a bit value which currently gets displayed as 'True' or
'False'.

I would like to be able to display an image of a tick when this value is
true, and have placed an asp.net image control within the relevant template column. I presume I can achieve this within the databinding event of the
grid, but am unsure as to quite how!

I would be grateful if anyone could shed some light on this!

Many thanks, Carl
ca**********@m-s-solutions.co.uk

Nov 17 '05 #2
Hi Carl,

From what I can see you are in the right direction but you cannot use
the FindControl method of the DataGrid itself to find a control in a
templatecolumn... there would be one control with that ID for each row
in the grid.

So... instead of

dgExistingFiles.Controls("imTick").Visible = True

you need to use the DataGridItemEventArgs e param that is passed in to
get
a reference to the control. For ex: if your image is the only control
in the first column of the datagrid:

e.Item.Cells[0].Controls[1].Visible = false

would do the trick (Controls[1] because the system always adds a
literal control before your server control, at least this is what I
have found)

If its in the second column use Cells[1] instead, etc... If there are
other controls in the column you will have to play around with the
Controls[] index to find the right one.

John
"Carl Howarth" <ca**********@m-s-solutions.co.uk> wrote in message news:<#d**************@TK2MSFTNGP11.phx.gbl>...
Thanks Jon,

This is the way in which I got around the problem, I would however be v
interested to find out how to alter a control's properties from the backend
code... could anybody point me in the right direction?

Thanks, Carl

"Jon Sequeira" <js******@twcny.rr.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
In the .aspx file you could set the Image's Visible property to the
databound value, something like this:

<asp:Image Visible="<%# CBool(DataBinder.Eval(Container,
"DataItem.showTickGraphic") %>"> </asp:Image>

If this will acheive what you're looking for, it's a little less complex
than diving into the databinding events.

Hope that's useful,

--Jon

"Carl Howarth" <ca**********@m-s-solutions.co.uk> wrote in message
news:#q**************@TK2MSFTNGP11.phx.gbl...
Hi,

I have a datagrid being populated using an sqldatareader. One of the
columns returns a bit value which currently gets displayed as 'True' or
'False'.

I would like to be able to display an image of a tick when this value is
true, and have placed an asp.net image control within the relevant template column. I presume I can achieve this within the databinding event of the grid, but am unsure as to quite how!

I would be grateful if anyone could shed some light on this!

Many thanks, Carl
ca**********@m-s-solutions.co.uk


Nov 17 '05 #3

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

Similar topics

0
by: Morné | last post by:
Hi how do I validate a text value in a datagrid e.g. the user is only allowed to type in a Y or a N. I specifically have a problem with using the PropertyDescriptorCollection. I get the...
2
by: T.H.M | last post by:
Hello I have a web form with MultiPage that contain DataGrid My HTML code in the aspx page: <iewc:multipage id="MP1" style="Z-INDEX: 101; LEFT: 225px; POSITION: . . ."/> >iewc:PageView...
2
by: wolfgang wagner | last post by:
hi all! im trying to edit data in a datagrid (like described here: http://aspnet.4guysfromrolla.com/articles/071002-1.aspx) but if i click the edit button i get the following error invalid...
1
by: Anna | last post by:
I have a simple DataGrid that displays a list of characteristics and allows you to edit a description for each characteristic. The query that feeds this involves a join, as the characteristics and...
3
by: Larry Woods | last post by:
I have a datagrid that is carrying all fields of a record...except one. Now I want to update the underlying database via a dataadapter. The update is working but the field that is "left out" is...
5
by: antonyliu2002 | last post by:
I want to put results from more than 1 sql queries into a signle datagrid, For example, in my web application, I submit this following query to my oracle database: Select NetID, Firstname,...
15
by: glenn | last post by:
Hi folks, I have a DropDownList in a DataGrid that is populated from records in a database. I want to add a value that might be a string such as "Select a Company" for the first item since an...
1
by: Alex Maghen | last post by:
I have a DataGrid on my ASPX and I'm confused about the interaction with the page based on whether the page is just loading or is being reloaded with a call to the SortCommand of the DataGrid: ...
0
by: | last post by:
I have a question about spawning and displaying subordinate list controls within a list control. I'm also interested in feedback about the design of my search application. Lots of code is at the...
0
by: rupalirane07 | last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error: NullReferenceException error Any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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,...
0
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.