at-hex
at-hex

Reputation: 3130

Format datetime to lowercase in GridView's inner Label

Here is a GridView snippet with dates from database:

<asp:GridView ID="grid" runat="server" ...>
<asp:TemplateField HeaderText="Date">
<ItemTemplate> 
<asp:Label ID="dateLbl" runat="server" Text='<%# Bind("datevalue", "{0:dd MMM yy, ddd}") %>' />
</ItemTemplate>
...

Dates look something like 07 Jan 13, Mon

I want them to look like 07 jan 13, mon

Is it possible?

Upvotes: 1

Views: 740

Answers (2)

MahaSwetha
MahaSwetha

Reputation: 1066

You can do it in gridview rowdatabound event:

protected void grid_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        Label dateLbl= (Label)e.Row.FindControl("dateLbl");
        string date=dataLbl.text.tolower();
        dateLBl.text=date;
    }          
}

Upvotes: 0

at-hex
at-hex

Reputation: 3130

Ok. The only option available is CSS :)

<asp:Label ID="accdateLbl" runat="server" Text='<%# Bind("accvaluedate", "{0:dd MMM yy, ddd}") %>' CssClass="grid_date" />

.grid_date
{
    text-transform: lowercase;
}

Now it works!

Upvotes: 1

Related Questions