Click here to Skip to main content
16,016,910 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
System.IO.StringWriter sw = new System.IO.StringWriter();

foreach (DataTable dt in ds.Tables)
{
GridView grd = new GridView();

grd.DataSource = dt;


grd.Style.Remove("border-collapse");
grd.Attributes.Remove("style");
grd.Attributes.Remove("border");
grd.Attributes.Add("style", "display:none;");

grd.DataBind();


HtmlTextWriter htw = new HtmlTextWriter(sw);
grd.RenderControl(htw);
grd = null;
}


In this above code im passing datatable as source to gridview
when i quick watch on htw it return result as below:-

XML
base {System.IO.TextWriter} = {<div>
    <table cellspacing="0" rules="all" border="1" style="border-collapse:collapse;display:none;">
        <tr>
            <th scope="col">idUsr</th><th scope="col">cdCode</th><th scope="col">idGrp</th><th scope="col">sNamePrefix</th><th scope="col">sNameFirst</th>...



in this by default border attribute and style added to table how could i remove this from table structure?Please Help!
Posted

Try something like

C#
grd.RowStyle.CssClass = "BorderClass";

grd.ItemStyle.CssClass = "BorderClass";


Css Class:

C#
.BorderClass
{
  border-style:none;
}


Hope this helps...
 
Share this answer
 
Comments
shriti 3 18-Dec-13 6:14am    
Thanks for the help.I resolved by writing below code

grd.Gridlines=Gridlines.None;
grd.RowStyle.BorderStyle = BorderStyle.None;
grd.RowStyle.BorderWidth = Unit.Pixel(0);
grd.Gridlines=Gridlines.None;
grd.RowStyle.BorderStyle = BorderStyle.None;
grd.RowStyle.BorderWidth = Unit.Pixel(0);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900