CheckBox.Checked property in the Header of a Dynamically created DataGrid Column 
Author Message
 CheckBox.Checked property in the Header of a Dynamically created DataGrid Column

SOME BACKGROUND:

I have created a web server control datagrid in which columns are
dynamically added and dynamically bound to a SQL Server stored
procedure.  The datagrid act as an editable cross tab display with
products listed vertically down the left column and distributors
displayed horizontally in the header.  The detail displays price that
each product is sold by each distributor.  Since the price for a
product may be different from one distributor to another, the cross
tab approach was necessary.  As new distributors are added, the system
automatically adds the necessary columns.   Since the data source can
change from day to day with the addition or removal or distributors, I
have written code that dynamically builds the SQL on every page load
and checks to see if the SQL matches the current stored procedure.  If
it does not, then the existing stored procedure is dropped and a new
stored procedure is created.  This approach maximizes the performance
because the query execution plan is only created when distributors are
either added or removed.

The dynamically added columns use the InstantiateIn method with
implements the ITemplate interface. The following code is used for
columns that need to be dynamically bound to the data source:

If (this control will be bound to a data source) Then
    AddHandler (controlname).DataBinding, AddressOf (databind method)
    container.Controls.Add (controlname)
Else
    container.Controls.Add (controlname)
End If

THE PROBLEM:
All this works great except for the following two issues:
1)       In the header of certain dynamically added columns, I have
added a user-editable checkbox which is used to give users control
over certain update processes, turning the process on for specific
distributors while turning it off for others.  I can't figure out how
to evaluate the checkboxes state in code because when control returns
to the server, the columns no longer exist until they are re-created.
If the checkbox was set ON, how will the system know to recreate the
checkbox with checked property equal to true?  Am I missing something
here?

2)       Also in the header I use Link Buttons for the header text.
This gives the grid header a button control to be used for sorting.
However, I can't figure out how to dynamically associate an event
handler to the link buttons Click event.  Since it is contained in the
datagrid, when I click a linkbutton, the form gives control back to
the server, but I can't figure out how to identify which control fired
the event.

Any help would be extremely appreciated.



Fri, 24 Jun 2005 01:13:25 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Dynamically Added Datagrid Template Column - Checkbox.Checked state in Column Header

2. How to align column header differently from column in windows datagrid

3. Adding and deleting columns dynamically, repeating row headers

4. Changing datagrid column sizes dynamically

5. Dynamically set column settings for a Datagrid

6. How to access the dynamically created checkbox in vb.net

7. how can I dynamically create checkboxes in VB.NET

8. dynamically creating checkboxes

9. Dynamically created CheckBox's?

10. DataGrid - Column Header color

11. Checkbox within a Datagrid column

12. Column header height on a windows datagrid control

 

 
Powered by phpBB® Forum Software