并在编程方式创建GridView控件插入

并在编程方式创建GridView控件插入

本文介绍了编辑,删除,并在编程方式创建GridView控件插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我面临的一个问题。事实上,我已经创建了一个数据绑定GridView控件编程。问题是我要成为互动(更新,删除,插入和所有钻),但只有使用C#,因为我已经创造了它编程。
下面是在GridView创建的code that'ive

So I'm facing a problem. In fact i have created a databound GridView programmatically. The problem is I want to be interactive (update , delete, insert and all that drill) but only using c# since i have created it programmatically.Here is the code that'ive created with the GridView

 GridView grid = new GridView();
            //CSS
            grid.CssClass = "grid";
            grid.ForeColor = System.Drawing.Color.Gray;
            grid.ShowFooter = true;
            grid.AlternatingRowStyle.CssClass = "gridAltRow";
            grid.RowStyle.CssClass = "gridRow";
            grid.FooterStyle.CssClass = "gridFooterRow";
            grid.DataKeyNames = new string[] { "ID" };
            grid.RowCommand




            //End Css

            grid.AutoGenerateEditButton = true;

            grid.DataSource = element.GetElementByRubric(testrub.ID);

            panel.Controls.Add(grid);
            grid.DataBind();

            TabContainer1.Tabs.Add(panel);

如你所见,我添加了一个编辑按钮,但它没有做任何事情的。有没有人有什么建议?

as you can see i added an edit button but it does nothing of course. Does anyone have any suggestions ??

THX

推荐答案

您必须写函数用于更新在GridView的onrowupdating事件数据库,以使编辑链接的工作。

You have to write the function for updating the database in onrowupdating event of the gridview to make the edit link work.

这篇关于编辑,删除,并在编程方式创建GridView控件插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 09:05