How do we add border to a datagrid?
I have a datagrid which displays data read from an xml file.
DataSet ds = new DataSet();
ds.ReadXml(Se开发者_Go百科rver.MapPath(@"App_Data\Mediaplan.xml"));
DataView dv = ds.Tables[1].DefaultView;
dv.RowFilter = "ActivityId=" + DropDownList1.SelectedValue;
dg.DataSource = dv;
dg.DataBind();
PlaceHolder1.Controls.Add(dg);
}
My doubt is how do I add a border to this datagrid? I need a simple black border around the grid. If it can only be done in HTML side, plz let me know how. I am a new bee to .NET. I am building an ASP.net web app using VS 2010.
Thanks in advance, Pooja
You can add the border to datagrid by providing the BorderColor, BorderWidth attributes to the Datagrid.
Here is the example......
<asp:DataGrid ID="dg1" runat="server" BorderColor="Black" BorderWidth="2px"
CellPadding="0">
</asp:DataGrid>
If you are defining in code behind then try this adding in code behind.
dg1.BorderWidth = Unit.Pixel(2);
dg1.BorderColor = System.Drawing.Color.Black;
精彩评论