Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Adding a control to the DataGrid collection controls

Reply
Thread Tools

Adding a control to the DataGrid collection controls

 
 
Giorgio Parmeggiani
Guest
Posts: n/a
 
      10-09-2003
Hi
I have built a DataGrid custom adding a panel of selection
automatically produced in base to the columns of the
DataGrid
The panel has directly been added to the collection
controls of the datagrid: datagrid.Controls.Add
(_panelFilter)

The problem is that for all the contained controls in the
panel the event OnPreRender is never recalled, besides for
the controls DropDownList and other custom controls
doesn't work the ViewState.

My question is: Can to directly add some controls to the
collection of the DataGrid have some problems, can I use
another way to add the panel of selection?

Giorgio
 
Reply With Quote
 
 
 
 
Jacob Yang [MSFT]
Guest
Posts: n/a
 
      10-10-2003
Hi Giorgio,

Thank you for using Microsoft MSDN managed newsgroup.

Use the Controls collection to manage the child controls contained in a
data listing control. We can add controls, remove controls, or iterate
through the server controls in the collection.

Please refer to the following URL for a simple sample regarding this issue.

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwebuiwebcontrolsbasedatalistclasscontro lstopic.asp

For your special case, currently I have not a specific answer. Is it
possible for you to send me a simple testing sample and tell me how to
reproduce your problems step by step on my side? I certainly appreciate
your time. My email box is http://www.velocityreviews.com/forums/(E-Mail Removed).

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

 
Reply With Quote
 
 
 
 
Jacob Yang [MSFT]
Guest
Posts: n/a
 
      10-13-2003
Hi Giorgio,

Thank you for your update.

I am researching the testing sample now. More time is needed for this
issue. Thank you for your understanding. I will contact you as soon as
possible.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


________________________________________
From: Giorgio Parmeggiani [(E-Mail Removed)]
Sent: October 12, 2003 1:27
To: Jacob Yang
Subject: Example of adding a control to the DataGrid controls collection

Hi Jacob

Thanks for your rapids answer!

I have prepared an simple example of the DataGrid Custom.
The class calls DataGridFilter (contained in DataGridFilterExample.zip) and
is used in the example page default.aspx (contained in
DataGridFilterTest.zip).

Calling the page default.aspx is loaded a DataGrid reading the table
"Clienti" of Northwind.mdb (it uses the database that I have attached)

In the DataGrid custom I have defined 4 columns (BoundColumnFilter extended
by BoundColumn) in base to which a panel of filter is created above to the
DataGrid.

Every column have an attribute that establishes if he must be visualizes in
the filter as TextBoxFilter (class extended by TextBox) or DropDownFilter
(class extended by DropDownList). I have foreseen in the example page three
columns as TextBox and the last as DropDown.

You can easily verify that, performing a postback, the TextBox maintains
his value thanks to the ViewState while the DropDown doesn't maintain it (I
am forced to recall the method "setChildDataSource" with the parameter
load=true to manually load the element selected through Request.Form)

Besides if you put a BreakPoint inside the method OnPreRender of
DropDownFilter you can easily verify that this is never recalled.

Where am I wrong? Can you advise me to resolve the problem?

Thanks still for your interest to my problem.

Ciao
Giorgio


P.S. The example that I have sent you doesn't filter the elements of the
DataGrid I have removed this it seems for simplifying him/it.

 
Reply With Quote
 
Jacob Yang [MSFT]
Guest
Posts: n/a
 
      10-14-2003
Hi Giorgio,

I have done a lot of research regarding this issue and reproduced the
problem on my side. The followings are my testing steps:

1. Extract DataGridFilterTest under the wwwroot directory.

2. In IIS, create DataGridFilterTest as a web application.

3. Extract DataGridFilterExample.

4. Open the solution.

5. Set DataGridFilterTest as the startup project.

6. Set default.aspx as the startup page.

7. Set the correct data source path in the web.config file.

8. Build and run the web application.

9. Type ˇ°Jacob Yangˇ± in the Name text field.

10. Select ˇ°Titolareˇ± in the Position Dropdownlist.

11. Click the ˇ°Cercaˇ± button.

12. We can see that the ˇ°Jacob Yangˇ± is maintained but the ˇ°Titolareˇ±
is not.

I have not found a specific solution for your testing sample. Based on my
research and experience, I would like to share the following information
with you.

In the custom control, you are first setting the properties and adding the
list items. After that you are adding the control to the control tree.
Note that we don't start tracking the viewstate until unless the control is
added to the control tree. So, we don't save the viewstate for these
listitems. Please refer to the following URLs regarding this issue.

http://msdn.microsoft.com/chats/vstu...dio_082202.asp
ˇ°ˇ*
: bryan : I have a custom server control that has a DropDownList called
List in it. I got AutoPostBack to work on the list by adding the list to
the controls collection, but whenever it posts back, the SelectedIndex = 0.
ˇ*ˇ±
http://www.dotnet247.com/247reference/msgs/7/36488.aspx

http://www.dotnet247.com/247reference/msgs/6/31629.aspx
ˇ°I have a dropdownlist on my asp.net form. When I select an item in the
dropdownlist it highlights and appears at the top of the list. But when I
click my submit button and redisplay my page the first item in the
dropdownlist appears not the item I selected. How can I keep the selected
item highlighted?
ˇ*ˇ±

I hope it helps.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided ˇ°as isˇ± with no warranties and confers no rights.

 
Reply With Quote
 
Jacob Yang [MSFT]
Guest
Posts: n/a
 
      10-22-2003
From: Jacob Yang
Sent: October 20, 2003 13:28
To: '(E-Mail Removed)'
Subject: RE: Adding a control to the DataGrid collection controls

Hi Giorgio,

I am glad to know that the problem is resolved in your testing sample.

Based on my research and experience, your solution for the example project
is correct. I am not sure about when it does not work in your production
code.

Looking at the nature of this issue, I would highly recommend you contact
Microsoft Product Support Services since it would require intensive
troubleshooting which would be done quickly and effectively with direct
assistance from a Microsoft Support Professional. Thank you for your
understanding.

Microsoft support home page:
http://support.microsoft.com.
To view support options:
http://support.microsoft.com/default...d=sz;en-us;top.
To submit an online request:
http://support.microsoft.com/default...incidentsubmit.

I hope it helps.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


-----Original Message-----
From: (E-Mail Removed) [(E-Mail Removed)]
Sent: October 18, 2003 17:50
To: Jacob Yang
Subject: RE: Adding a control to the DataGrid collection controls

Hi Jacob

Thankyou for your response.

I have tried following your indications and are successful to resolve the
problem in the example that I have made to see you.
In order to resolve the problem I have:

- In the OnInit method (override) created dynamically the filter panel.
- In the OnLoad method (override) added the panel to the collection
controls

So the viewstate is correctly loaded.

But in my production code (is more complicated) the problem is not resolved
and the viewstate seems not to be loaded.

Do you think that my solution for the example project is correct ?? How can
i find a solution for my production code?

Can i send you a copy of my production code??

Thankyou in advance!

Giorgio

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
this.Controls.Add(Control) Does Not Add Control to child collection (this.Controls.Count == 0) Chad Scharf ASP .Net 3 10-18-2007 03:53 PM
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Řyvind Isaksen ASP .Net 1 05-18-2007 09:24 AM
WebControl - CollectionEditor Problem. Changing id property of new added collection item causes not adding item to collection - Sergio ASP .Net Web Controls 0 05-29-2006 06:20 AM
Adding to collection from controlDesigner only produces end tag for the collection. Don ASP .Net Building Controls 0 07-22-2005 09:31 PM
Adding controls to Page.Controls collection Jeremy Ames ASP .Net 5 03-05-2004 08:33 PM



Advertisments