使用CSharp,如何设置数据表的宽度,高度,边框颜色等。我想在表格中添加一些功能,让外观看起来很酷。
for (int i = 0; i <= 5; i++)
{
if (myQuantity[i]!=null && myQuantity[i].Length>0)
{
row = dt.NewRow();
row["Name"] = myName[i];
row["Quantity"] = myQuantity[i];
row["Price"] = myPrice[i];
c = Convert.ToInt32(myQuantity[i]);
int price = Convert.ToInt32(myPrice[i]) * c;
row["Amount"] = price;
// row["ImageUrlPath"] = "~/Images/cross.png";
dt.Rows.Add(row);
}
}
// dt.Rows[0].Delete();
GridView1.DataSource = dt;
GridView1.DataBind();
}
答案 0 :(得分:4)
你不能在DataTable上执行此操作,但可以在GridView的行上
示例:
void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.CssClass="your css class";
}
}