gridview arrange strings data right
1)Is it possible to arrane strings to the right? 2开发者_如何学JAVA)Is it possible in case The value of the field is null to have "-" in the corresonding gridview field
protected void Page_Load(object sender, EventArgs e)
{
GridView1.Columns[2].ItemStyle.HorizontalAlign = HorizontalAlign.Right;
}
void GridView_RowDataBound(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//Due to the fact that DBnull value by default would be just empty string
e.Row.Cells[1].Text = (string.IsNullOrEmpty(e.Row.Cells[1].Text))?"-":e.Row.Cells[1].Text;
}
}
精彩评论