frenchie
frenchie

Reputation: 51937

gridview boundfield

How do you access the Boundfield object?

I have OnDataBinding="MyFunction" on the aspx and then in the code behind I have protected void MyFunction(object sender, Gridview e). I can't locate the Boundfield object. I can access the first column throught e.Column[1] but I'm interested in the DataFormatString property and that's a property of the Boundfield object.

thanks.

Upvotes: 1

Views: 1759

Answers (1)

Tim Schmelter
Tim Schmelter

Reputation: 460108

If you for example want to show the time only(and your 2. column is a Date-Column):

VB.Net

DirectCast(Me.GridView1.Columns(1), BoundField).DataFormatString = "{0:t}"

C#

((BoundField)(this.GridView1.Columns[1])).DataFormatString = "{0:t}";

Upvotes: 3

Related Questions