Regarding the index selection style of the columns i suggest you do the following. i ran into this problem but i was going to set values dynamically using an API
so what i did was this :
keep in mind .CastTo<T>
is simply ((T)e.Row.DataItem)
and you have to call DataBind()
in order to see the changes in the grid. this way you wont run into issues if you decide to add a column to the grid.
protected void gvdata_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
var number = e.Row.DataItem.CastTo<DataRowView>().Row["number"];
e.Row.DataItem.CastTo<DataRowView>().Row["ActivationDate"] = DateTime.Parse(userData.basic_info.creation_date).ToShortDateString();
e.Row.DataItem.CastTo<DataRowView>().Row["ExpirationDate"] = DateTime.Parse(userData.basic_info.nearest_exp_date).ToShortDateString();
e.Row.DataItem.CastTo<DataRowView>().Row["Remainder"] = Convert.ToDecimal(userData.basic_info.credit).ToStringWithSeparator();
e.Row.DataBind();
}
}