Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good day to everyone.
can anybody help me with my codes?
I want to create a dynamic column in gridview..

My sample:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"   DataKeyNames="EmployeeID" DataSourceID="ObjectDataSource1">
     <columns>
        <asp:BoundField DataField="LastName" HeaderText="LastName"        SortExpression="LastName" />
        <asp:BoundField DataField="FirstName" HeaderText="FirstName"          SortExpression="FirstName" />
        <asp:BoundField DataField="Title" HeaderText="Title"          SortExpression="Title" />
        <asp:BoundField DataField="HireDate" HeaderText="HireDate"          SortExpression="HireDate" />
    </columns>


My problem is how to create a dynamic column. Meaning to say all data inside <column> will be created dynamically at code-behind. It can be either BoundField or by ItemTemplate (i prefer ItemTemplate please) the final code would be

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="EmployeeID" DataSourceID="ObjectDataSource1">
<column>
...all code here will be created at code behind...
</column>
Posted
Updated 9-Feb-11 16:47pm
v2

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900