开发者

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;

        }

    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜