Datagrid html output without <table> tags

I need the html ouput from our custom datagrid to start with a <tr> instead of a <table>.  The output will be placed inside of a surrounding table.  How can I strip the <table> tags off the top and bottom of the datagrid output?  
Summit-ITAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mmarinovCommented:
Hi Summit-IT,

just use a repeater control
you can define what should be rendered

Regards!
B..M
0
Summit-ITAuthor Commented:
We can't use a repeater control because we have a custom datagrid that has all of our feautures already built in.  We have to make it work with the datagrid control.  Any suggestions?
0
AerosSagaCommented:
I don't think you can sorry;(

Aeros
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

AerosSagaCommented:
could you not just insert the whole <table> inside a <tr>??
0
Summit-ITAuthor Commented:
I know it sounds crazy not to just put it inside of <tr> but thats not an option for us.  Is there maybe away to just render the table rows and table cells from the datagrid without the <table> tag?  Thanks
0
AerosSagaCommented:
no there isn't
0
riyasjefCommented:
Try this

<table>
<tr>
<td width="100%">
<asp:dataGrid
.......
......
/>

</td>
</tr>
</table>

RJ
0
riyasjefCommented:
Or something like this

System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);

DataGrid dg=new DataGrid;
...................
....................
dg.RenderControl(oHtmlTextWriter);
String strCode=oStringWriter.ToString();

// strip <table> from  strCode using RegExp

Response.Write("<table>");
Response.Write(strCode);
Response.Write("</table>");

RJ
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AerosSagaCommented:
isn't that just goint to add an extra table tag before and after???
0
nitrogenxCommented:
NOTE: Partial points to riyasjef if this works

aspx:
    //Your table tag
    <asp:DataGrid Runat=Server ID=DataGrid1 Visible=false></asp:DataGrid>
    <asp:Label Runat=Server ID=DataGridRender></asp:Label>
    //Your end table tag

codebehind:
        System.Text.StringBuilder stringBuilder1 = new System.Text.StringBuilder();
        System.Web.UI.HtmlTextWriter htmlTextWriter1 =
            new System.Web.UI.HtmlTextWriter(
                new System.IO.StringWriter(stringBuilder1));
        DataGrid1.Visible = true;
        DataGrid1.RenderControl(htmlTextWriter1);
        DataGrid1.Visible = false;
        string text = stringBuilder1.ToString();
        int start = text.IndexOf('>') + 1;
        int end = text.LastIndexOf('<');
        if (start < end && start != -1 && end != -1)
            DataGridRender.Text = text.Substring(start,end-start);

This works because the table tag should never contain a premature > and the </table> tag should never have a premature < I am 99.9% sure that there is no situation you will be working with that will put a > somewhere in the table tag, but be forewarned.
0
Summit-ITAuthor Commented:
I ended up making it work by rendering the control from start to finish using:

protected override void Render(HtmlTextWriter writer)


I accepted riyasjef 's answer because he gave me the idea to start with the HTMLTextWriter.

I wanted to give partial points to nitrogenx but I couldn't find the partial points option.  My mistake.

Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.