Hello,
I have a bounded gridview with 14 rows and 6 columns. I want to add a additional column to it named as date and it shd be unbounded. Basically i want to display incremental date in this column such as
06/01/2007
06/02/2007
06/03/2007
06/04/2007
06/05/2007
06/06/2007 and so on
i am using asp.net C#
Plz help
Use a template column and add a label to this to hold any data that you wish. Then in the code behind use the findcontrol method and assign the text of the label.
Here is a quick example.
[HTML]<asp:GridView id="GridView1" runat="server">
<Columns>
//whatever you already have +
<asp:TemplateField>
<ItemTemplate>
<asp:Label id="lblDate" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>[/HTML]
Code Behind:
- for(int i=0; i<GridView1.Rows.Count;i++)
-
{
-
//create new label with the contents of lblDate
-
Label labelDate = (Label)GridView1.Rows[i].FindControl("lblDate");
-
labelDate.Text = DateTime.Now.AddDays(i);
-
}
Nathan