Rendering the ItemStyle of a GridView row

C

Chris Ludlow

I've created a GridView control that uses TemplateFields and ItemStyle tags.
What I've done is dropped this control on a page, and am using other
pages/scripts to call this GridView page and get the rendered HTML of a
certain row. The problem I am having, is when I find the row I want to
render, the rendered output does not contain any of the ItemStyle attributes
that are defined in the aspx html page.
It seems like if I define a style in the aspx page, the code-behind for the
GridView does not see any of these styles, so the rendercontrol method does
not output any style attributes for my rows and cells. Can anyone point me
in the right direction?

Here is a brief snipppet:
an example of one of my aspx Gridview columns:

<Columns>
<asp:TemplateField>
<ItemStyle Width="15px" />
<ItemTemplate>
<!-- Checkboxes -->
<input type="checkbox" name="<%#
DataBinder.Eval(Container.DataItem, DGConst_ClientID).ToString()%>"
value="true" onclick="Checkbox_Click(this);" id="checkboxes" />
</ItemTemplate>
</asp:TemplateField>

MY CODE BEHIND:

myGrid.GridView1.DataSource = ds;
myGrid.GridView1.DataBind();
myGrid.GridView1.ControlStyle.AddAttributesToRender(htmlTW);
myGrid.GridView1.Rows[0].RenderControl(htmlTW);
htmlTW.Flush();

the htmlTextWriter, htmlTW, never gets the row or cell styles that exist in
the aspx templates. Of course, the GridView control renderes all styles
properly when returned fully to the page after the DataBind() event. It's
when I try to pick off an individual row using the RenderControl method that
the styles disappear. What am I doing wrong?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top