Change header text of columns in a GridView

前端 未结 6 613
天涯浪人
天涯浪人 2020-12-08 14:26

I have a GridView which i programmatically bind using c# code. The problem is, the columns get their header texts directly from Database, which can look odd when presented o

6条回答
  •  情话喂你
    2020-12-08 15:03

    On your asp.net page add the gridview

    
    
    

    Create a method protected void method in your c# class called GridView1_RowDataBound

    as

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            e.Row.Cells[0].Text = "HeaderText";
        }
    }
    

    Everything should be working fine.

提交回复
热议问题