Advertisement

01.12.2008 at 01:48AM PST, ID: 23077696
[x]
Attachment Details

How to tell the datatype in a cell in a gridview ?

Asked by SHJ_LUX in Delphi.net Programming, Programming for ASP.NET

Tags: RAD 2007, Delphi for ASP.NET

For various reasons I initialize datetime fields in a SQL 2005 table to 0 instead of NULL, meaning the fields will show something like '1900-01-01' in a gridview with AutoGeneratedFields.

To get rid of these I use the following code in the Gridviews RowDataBound event:

If e.Row.RowType = DataControlRowType.DataRow Then
begin
  for I := 0 to e.Row.Cells.Count - 1 do
  begin
    if (pos(InitDateStr,e.Row.Cells[i].text) > 0) then e.Row.Cells[i].text := '';
  end;
end;

It works nicely... but for cells of all types. Not just datetime cells. It means it also empties a stringcell, should the content happen to include the text '01-01-1900' (format depending of the language settings).

So, how can I tell if a cell is bound to a datetime / smalldatetime field in the SQL DB, to only clearing the right cells ?Start Free Trial
[+][-]01.12.2008 at 04:21AM PST, ID: 20643535

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.12.2008 at 05:15AM PST, ID: 20643668

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.12.2008 at 07:36AM PST, ID: 20644163

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.12.2008 at 02:23PM PST, ID: 20645540

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.18.2008 at 01:28PM PST, ID: 20923618

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.23.2008 at 07:47AM PST, ID: 20965327

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Delphi.net Programming, Programming for ASP.NET
Tags: RAD 2007, Delphi for ASP.NET
Sign Up Now!
Solution Provided By: SHJ_LUX
Participating Experts: 1
Solution Grade: A
 
 
[+][-]02.23.2008 at 08:51AM PST, ID: 20965577

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628