Hi,
I've got a column which dispalys the number of days an item has been in stock. I've implemented this as as GridTemplateColumn with a label for the ItemTemplate. I couldn't use a GridCalculatedColumn as this does not work with dates. The code in the ItemDataBound event is as follows:
I've got a column which dispalys the number of days an item has been in stock. I've implemented this as as GridTemplateColumn with a label for the ItemTemplate. I couldn't use a GridCalculatedColumn as this does not work with dates. The code in the ItemDataBound event is as follows:
if (e.Item is GridDataItem)
{
GridDataItem dataItem = e.Item as GridDataItem;
Label label = (Label)dataItem.FindControl("DaysInStock");
label.Text =
DateTime.Now.Subtract(DateTime.Parse(dataItem["DateIntoStock"].Text)).Days.ToString();
}
I also want to be able to sort on this column. How can I implement this?
Thanks,
Stuart