Click here to Skip to main content
15,914,162 members
Home / Discussions / C#
   

C#

 
GeneralRe: RTD (real Time Data) problem Pin
Dave Kreskowiak2-Feb-05 4:38
mveDave Kreskowiak2-Feb-05 4:38 
Questionhow to read an xml file Pin
Bhupendr2-Feb-05 1:13
Bhupendr2-Feb-05 1:13 
AnswerRe: how to read an xml file Pin
Gavin Jeffrey2-Feb-05 3:00
Gavin Jeffrey2-Feb-05 3:00 
Generalagain: how to read an xml file Pin
Bhupendr2-Feb-05 18:01
Bhupendr2-Feb-05 18:01 
GeneralRe: again: how to read an xml file Pin
Gavin Jeffrey2-Feb-05 19:30
Gavin Jeffrey2-Feb-05 19:30 
GeneralExtract data and create xml for input Pin
dhol2-Feb-05 0:41
dhol2-Feb-05 0:41 
GeneralRe: Extract data and create xml for input Pin
Colin Angus Mackay2-Feb-05 2:47
Colin Angus Mackay2-Feb-05 2:47 
GeneralDataGrid (web) events not working when using collection class Pin
acidek2-Feb-05 0:35
acidek2-Feb-05 0:35 
I know subject sounds a bit odd but it's the most appropriate one I could come up with. After 1,5 year of c-sharping I cannot explain and solve my problem.

The thing is:
1. I'm working on my own inherited DataGrid class
2. I want to embed certain functionality in the grid (custom paging, sorting, filtering, etc.)
3. To ease programmatic creation of an instance of my control I introduced a collection class (AcidColumnCollection) of an object of AcidColumn type. This is really simple class which store information about the columns (if a column allows filtering, for instance).
4. The problem appears in ItemCreated method when I want to add a TextBox to the header cell (for filtering purposes). Have a look at this code snippet:

protected override void OnItemCreated(DataGridItemEventArgs e)
{
...
// insert glyphs in header cells for indication of order and texboxes
for(int i = 0; i < this.Columns.Count; i++)
{
// find a cell
TableCell tc = e.Item.Cells[i];
GenerateOrderInformation(tc, i);
GenerateFilterTextBoxes(tc, i);
}
...
}

Let's consider GenerateFilterTextBoxes method:

private void GenerateWhereTextBoxes(TableCell tc, int i)
{
string column = this.Columns[i].SortExpression;
// columns is an instance of AcidColumnCollection
// Filterable method checks whether a column which name is passed via this method's parameter should have a TextBox for filtering purposes.
if(columns.Filterable(column) == true)
{
// create controls to add
Label lblBreak = new Label();
TextBox txtBoxWhere = new TextBox();
// set properties
lblBreak.Text = "
";
// add them
tc.Controls.Add(lblBreak);
tc.Controls.Add(txtBoxWhere);
}
}

Basically I create AcidColumn object to store additional information about customised DataGrid columns. One of those is a property called Filterable. If it is true - a TextBox is added to that column. There no logic behind it so far, yet to be implemented. Simple as that.

What is the problem then? Well DataGrid events GO MAD - I click column 0 column 1 is sorted, I click column 2 - column 1 is sorted, I click on paging link, column 0 is sorted (!), the page is changed but the paging link does not change! It is really weird.

I made experiments and they ended in AcidColumnCollection.Filterable method. Look at this:

public bool Filterable(string p_name)
{
bool filterable = false;
foreach(AcidColumn col in this.List)
{
if(col.Name == p_name)
{
filterable = col.Filterable;
break;
}
}
return filterable;
}

ONLY if I use this collection method to examine filterable property and ONLY if I add TextBoxes to the datagrid header, the problem appears.

The last thing I did was replacing "return filterable" with "replace true" and... everything is FINE. PERF ECT. Change it back to filterable variable - the grid will not work.

Also if I use this Filterable method to check the property but DO NOT add any controls in GenerateWhereTextBoxes method - the grid beheaves normally.

I just do not know where the problem could lie. AcidColumn is a simple class. There's nothing behing Filterable property, nothing that could affect DataGrid events. And how come browsing through collection and checking its object properties in combination with adding controls to the grid generates such a strange problem!?

For your reference I'm enclosing Acid Column class:

public class AcidColumn
{
private string name;
private string type;
private bool filterable;
private int order;

public AcidColumn()
{
this.filterable = false;
}

public string Name
{
get { return name; }
set { name = value; }
}

public bool Filterable
{
get { return filterable ; }
set { filterable = value; }
}
}

Thanks for your advice,
Arek
GeneralReading text from a pdf file Pin
Member 16488292-Feb-05 0:24
Member 16488292-Feb-05 0:24 
GeneralRe: Reading text from a pdf file Pin
Colin Angus Mackay2-Feb-05 2:45
Colin Angus Mackay2-Feb-05 2:45 
GeneralShow ToolTip regardless of Enabled state Pin
Corinna John1-Feb-05 23:24
Corinna John1-Feb-05 23:24 
GeneralDropDownButton Pin
lee meng1-Feb-05 22:51
lee meng1-Feb-05 22:51 
GeneralRe: DropDownButton Pin
Corinna John1-Feb-05 23:35
Corinna John1-Feb-05 23:35 
Generalalways on top Pin
Mridang Agarwalla1-Feb-05 21:27
Mridang Agarwalla1-Feb-05 21:27 
GeneralRe: always on top Pin
Gavin Jeffrey1-Feb-05 21:31
Gavin Jeffrey1-Feb-05 21:31 
Questionsharepoint...???? Pin
Mridang Agarwalla1-Feb-05 21:23
Mridang Agarwalla1-Feb-05 21:23 
AnswerRe: sharepoint...???? Pin
Dave Kreskowiak2-Feb-05 2:03
mveDave Kreskowiak2-Feb-05 2:03 
Generalstarting stopping services Pin
Mridang Agarwalla1-Feb-05 20:00
Mridang Agarwalla1-Feb-05 20:00 
GeneralRe: starting stopping services Pin
spif20011-Feb-05 20:54
spif20011-Feb-05 20:54 
GeneralRe: starting stopping services Pin
Member 16488292-Feb-05 0:21
Member 16488292-Feb-05 0:21 
GeneralRe: starting stopping services Pin
Dave Kreskowiak2-Feb-05 2:00
mveDave Kreskowiak2-Feb-05 2:00 
GeneralSystem.Timers.Time class Pin
vyki_c1-Feb-05 18:27
vyki_c1-Feb-05 18:27 
GeneralRe: System.Timers.Time class Pin
Gavin Jeffrey1-Feb-05 21:36
Gavin Jeffrey1-Feb-05 21:36 
GeneralRe: System.Timers.Time class Pin
Stefan Troschuetz1-Feb-05 21:48
Stefan Troschuetz1-Feb-05 21:48 
GeneralRe: System.Timers.Time class Pin
vyki_c2-Feb-05 5:18
vyki_c2-Feb-05 5:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.