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

Dynamically Added Datagrid Template Column - Accessing the
Checkbox.Checked state

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 02:10:20 GMT  
 Dynamically Added Datagrid Template Column - Checkbox.Checked state in Column Header

Quote:
>-----Original Message-----
>Dynamically Added Datagrid Template Column - Accessing the
>Checkbox.Checked state

>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.
>.
> Hi David,

Try using some array to hold and transfer information
about the object's columns.

Do you know how to change foreground of specific cell in
DataGrid ?



Fri, 24 Jun 2005 15:17:26 GMT  
 
 [ 2 post ] 

 Relevant Pages 

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

2. Datagrid column reject input when added expression for parent columns

3. Template Column and Checkbox's

4. Checkbox in multi-column listbox or grid column?

5. Multi-column listbox w/3 columns of checkboxes

6. Multi-column listbox w/3 columns of checkboxes

7. Changing datagrid column sizes dynamically

8. Dynamically set column settings for a Datagrid

9. Dynamic DataGrid Template Columns using ascx

10. Datagrid web control problem: creating event handlers for contols in template columns

11. datagrid template columns question

12. Checkbox within a Datagrid column

 

 
Powered by phpBB® Forum Software