954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Dynamically adding/removing columns in datagrid

I create a report by allowing users to select certain criteria from dropdownlistbox.

Dropdowns: site, project, startDate, endDate, reporting level (summary or agent detail)

I have the following datagrid with 7 columns:

<asp:datagrid id="grdResults" runat="server" Height="50px" Font-Names="Tahoma" Width="900px" Font-Size="XX-Small" BorderColor="Silver" ForeColor="Black" PageSize="1" adding="1" AutoGenerateColumns="False" BorderStyle="Solid"
CellSpacing="1" HorizontalAlign="Center">
<Columns>
<asp:BoundColumn DataField="iMsSiteId" HeaderText="Site"></asp:BoundColumn>
<asp:BoundColumn DataField="sProject" HeaderText="Project"></asp:BoundColumn>
<asp:BoundColumn DataField="sCalldate" HeaderText="Calldate"></asp:BoundColumn>
<asp:BoundColumn DataField="sAgentId" HeaderText="Agentid"></asp:BoundColumn>
<asp:BoundColumn DataField="sFirstName" HeaderText="First Name"></asp:BoundColumn>
<asp:BoundColumn DataField="sLastName" HeaderText="Last Name"></asp:BoundColumn>
<asp:BoundColumn DataField="sRevenue" HeaderText="Revenue" DataFormatString="{0:$###,###.##}"></asp:BoundColumn>
</Columns>
</asp:datagrid>


When agent detail is selected from the dropdown the datagrid should contain agentid, firstname, and lastname columns.
When summary is selected those 3 columns shouldn't be visible.

How can I do this dynamically?

Thanks,
Ninel

ninelg
Newbie Poster
6 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

I have a solution to ur problem. Mail ur problem at [EMAIL="coolamit0072003@hotmail.com"]coolamit0072003@hotmail.com[/EMAIL] and I'll reply with solution.

Amit007
Newbie Poster
22 posts since Aug 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You