Toars I will smile to the world ^o^

14Sep/096

How to Set or Change the HeadText values in GridView control

GridView control offers us to bind the data and list the data in columns with nice format. However, when I want bind the HeadText properties for the columns of the data, I have to use this way:
--------------------------------------------------------------------------------

MyGridView.Columns[0].HeadText = "Head Text For Column 1";
MyGridView.Columns[1].HeadText = "Head Text For Column 2";

--------------------------------------------------------------------------------
Just FYI, *_*

Comments (6) Trackbacks (0)
  1. This method has some disadvantages. Whenever columns are added, removed or the order is changed, the code behind must be updated with the correct column index. On larger GridView’s with many columns, it’s thus easy to get errors. There should be a better way to do this.

  2. Thanks for the reply, however, I did spend sometime on finding a better way to work it out. I can not use MyGridView.FindControl(“Balala”). Maybe can use Javascript, I didnot try that. And thanks for the info.

  3. Super post, Need to mark it on Digg
    Charlie

  4. GridView outputs contents with ‘<table…' The <table element is slow to render in IE, because IE does not render the '<table' element until all HTML is loaded. One way to play around it is to avoid using <table, div is a nice alternative. However, GridView cannot output <div, even you change the render mode to 'flow', if I remember it correctly, but, a DataList can.

  5. GridView outputs contents with ‘table…’ The table element is slow to render in IE, because IE does not render the ‘table’ element until all HTML is loaded. One way to play around it is to avoid using table, div is a nice alternative. However, GridView cannot output div, even you change the render mode to ‘flow’, if I remember it correctly, but, a DataList can.

  6. hello! somebody maybe use google?

    google


Leave a comment


No trackbacks yet.