如何在ASP.NET中动态添加gridview列

问题描述:

我想通过点击按钮动态添加列



我尝试过:



我已经通过点击一个按钮添加了行但我想用相同的颜色添加列

I want to add column dynamically by clicking a button

What I have tried:

I have added rows by clicking a button but i want to add column by the same

我能想到的一个最简单的解决方案是,将GridView的autogenrate列设置为true并将新列添加到数据源并重新绑定网格。









您可以为此目的考虑jQuery。
One easiest solution i can think of is, set autogenrate column of GridView to true and add new columns to your datasource and rebind the grid.


Or

You can think of jQuery for this purpose.


('#yourGridId')。find('tr')。each( function()

{
('#yourGridId').find('tr').each(function()
{


(this).append(
(this).append(