vb.net 启用编辑选项未显示在 gridview 中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31108335/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 19:14:45  来源:igfitidea点击:

Enable editing option is not display in gridview

c#sqlasp.netvb.netvisual-studio-2010

提问by Rutul Mehta

I took Datasource and configure Connection String. From Advance option I have selected "generate Insert, Update, Delete Statements" but after configuration of datasource with gridview display only - "Enable Deleteing" - "Enable Shorting" - "Enable paging" - "Enable Selection"

我拿了数据源并配置了连接字符串。从高级选项中,我选择了“生成插入、更新、删除语句”,但在仅使用 gridview 显示配置数据源后 - “启用删除” - “启用短路” - “启用分页” - “启用选择”

but not showing me Enable Editingoption to gridview.

但没有向我显示对 gridview启用编辑选项。

what should I do?

我该怎么办?

回答by Litisqe Kumar

The Enable Editing check box appears in the smart tag panel only if the data source control to which GridView control is bound supports editing. For example, if the GridView control is bound to a SqlDataSource control, the SqlDataSource control's UpdateQuery property must contain a SQL Update statement.

仅当 GridView 控件绑定的数据源控件支持编辑时,智能标记面板中才会显示启用编辑复选框。例如,如果 GridView 控件绑定到 SqlDataSource 控件,则 SqlDataSource 控件的 UpdateQuery 属性必须包含 SQL Update 语句。

To enable default editing using the AutoGenerateEditButton property Select the GridView control, and in the Properties window, set AutoGenerateEditButton to true.

使用 AutoGenerateEditButton 属性启用默认编辑 选择 GridView 控件,然后在“属性”窗口中,将 AutoGenerateEditButton 设置为 true。

or

或者

In Source view, in the element, set AutoGenerateEditButton to true, as in the following example:

在源视图的元素中,将 AutoGenerateEditButton 设置为 true,如下例所示:

<asp:GridView Runat="server" ID="GridView1" 
  AutoGenerateEditButton="true" />

回答by Sarah Chaygani

You can just write the UpdateCommand and DeleteCommand in the "SqlDataSource" tag. This is an example that you can base on:

您可以只在“SqlDataSource”标记中写入 UpdateCommand 和 DeleteCommand。这是您可以基于的示例:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
  ConnectionString="<%$ ConnectionStrings:TechFocusConnectionString %>" 
  SelectCommand="SELECT * FROM [Comments]" 
  DeleteCommand="DELETE FROM [Comments] WHERE CodeCommentaire =@CodeCommentaire " 
  UpdateCommand="UPDATE [Comments] set Membre=@Membre, Article=@Article, Commentaire=@Commentaire, spam=@spam where CodeCommentaire =@CodeCommentaire">
</asp:SqlDataSource>

You can see there is the UpdateCommandand DeleteCommandwhere you can write down your own deleting or editing query and automatically the Deleting and Editing Options will be available. just don't forget to set the where clause with the primary key of your table, or else once you edit for example, all the rows will be edited.

你可以看到有就是UpdateCommandDeleteCommand在那里你可以写下自己删除或编辑查询,并自动删除和编辑选项将可用。只是不要忘记使用表的主键设置 where 子句,否则一旦您编辑,例如,所有行都将被编辑。