473,414 Members | 1,776 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

DataList ignores Styles when WebControlAdapter applies

Hi,
I registered a WebControlAdapter for any WebControl, that removes all
ID attributes (I actually do not need them). Everything works as
expected, but the DataList ignores any styles (ItemStyle,
SelectedItemStyle etc.). The DataList works as usual, i.e. it uses the
SelectedItemTemplate for the selected item.
Other controls, such as the TreeView, apply their styles properly.

Any idea what's going wrong? It seems like a bug for me. Currently,
the only workaround I see is to create a special adapter for the
DataGrid and render the table myself.

You can reproduce this by adding a .browser file like this:
<browsers>
<browser refID="Default">
<controlAdapters>
<adapter controlType="System.Web.UI.WebControls.WebControl"

adapterType="System.Web.UI.WebControls.Adapters.We bControlAdapter" />
</controlAdapters>
</browser>
</browsers>

In that case, the base class for WebControlAdapters is used. It should
render the control as usual, shouldn't it?

Kind regards, Sebastian

Aug 3 '07 #1
3 2223
....Now I see another issue with the DataList and WebControlAdapter.
When it is placed inside of a table cell, only the first data item is
rendered within that cell. The next item is rendered below the table
row containing the DataList - and so on! Every next item is rendered
before a table closes. Strange, isn't it?

I am using a GridView, this works fine with WebControlAdapter and even
within a DataList.

Kind regards, Sebastian

Aug 16 '07 #2
I am using a GridView, this works fine with WebControlAdapter and even
within a DataList.
Ok, this is not true when I replace the surrounding DataList by a
Repeater. But nevertheless, I found the source: Both, DataList and
DataGrid render a <tableelement around their usual table. This
disturbs the DOM, because <tableelements should contain rows and
cells.

I was able to fix that behaviour by overriding WebControlAdapter's
RenderBeginTag and RenderEndTag methods. This derived
WebControlAdapter cannot be used for all controls, because most of
them need their begin and end tags. (I was surprised that the CPU load
grows incredibly when using this for all controls. I think the
HtmlWriter does something wierd here.)

Unfortunately I still don't know what causes DataList and DataGrid to
discard their Item styles. Maybe I misunderstood some important things
about the ControlAdapter stuff. As I said, I just want to modify just
some aspects (i.e. remove IDs) instead of completely exchange the
rendering process.

Kind regards, Sebastian

Aug 17 '07 #3
Unfortunately I still don't know what causes DataList and DataGrid to
discard their Item styles.
Seems like I got it. The DataGrid simply does not need an adapter. So
I exclude the control like that:

<controlAdapters>
<adapter controlType="System.Web.UI.WebControls.DataList"
adapterType="" />
<adapter controlType="System.Web.UI.WebControls.GridView"
adapterType="" />
<adapter controlType="System.Web.UI.WebControls.WebControl"
adapterType="MyNamespace.MyWebControlAdapter" />
</controlAdapters>

That way, all controls (inclusive those created by DataList or
DataGrid) are rendered by my Adapter, but the DataGrid itself behaves
as normal.

Sebastian

Aug 17 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dirk Meusel | last post by:
Background: On my webform a simple datalist shows one column. The databind is done in the page_load event. In the ItemTemplate a linkbutton serves for providing the Select Command. Problem:...
4
by: Miguel Dias Moura | last post by:
Hello, I created a datalist in an ASP.Net / VB page. I display the image and price of a few products. When a user clicks an image I want to load the page "detail.aspx?number=id" and send the...
0
by: Shun Duke | last post by:
I have working code allowing me to nest repeaters inside datalists using relations and child rows but this does not allow me to acheive my goal. What I want to be able to do is display small...
1
by: Eirik Eldorsen | last post by:
I'm trying to set alternating bgcolor for a datalist with 2 columns. My problem is that its the alternating cell that get the bgcolor, not the row. Is it possible to set alternating color of rows?...
3
by: David Hearn | last post by:
I have a datalist that I have inserted a radio button into. The datalist populates with a list of items and each one has a radio button next to it. I need to use the radio button to allow the user...
2
by: yer darn tootin | last post by:
Here's the scenario: I have a javascript function taking the contents of a datalist ( content from a SQL db ) and opening it in a new window to allow the user to print. The pop-up window...
0
by: mumbaichef | last post by:
Hi, Can I apply style to datalist at runtime? The datalist control at runtime adds <tr>'s and <td>'s to the html and it messes up my desing. I was wondering if there is a way to apply styles to...
0
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i have a simple datalist on my web page that's attached to a sqldatasource that i specified on the quick task menu for the datalist. The datalist contains a linkbutton (command name =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.