我该怎么办编辑的GridView控件模板细胞的TextBox? [英] How can I do editable GridView Template Cells TextBox?

查看:347
本文介绍了我该怎么办编辑的GridView控件模板细胞的TextBox?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该怎么办编辑的GridView控件模板细胞的TextBox?


解决方案

  1. 使用命令列,设置 ShowEditButton =真的EditText =编辑按钮类型=链接

  2. 在您的模板列使用的ItemTemplate来形容列应类似于在非编辑模式下使用< ASP:标签=服务器ID =txtMyLabel文本='<%#的eval(MyFieldToDisplay)%>'/ >

  3. 使用您的列的EditTemplate显示您的编辑控件。恩。
    < ASP:文本框=服务器ID =txtMyFieldToEdit文本='<评估和演示%#(MyFieldToEdit)%>/>

  4. 在处理事件GridView.OnEditing这样



    保护无效myGridView_OnEditing(对象发件人,GridViewEditingEventArgs E)
    {
    myGridView.EditIndex = e.RowIndex;
    }




我相信这是正确的属性/属性名称,但我打字了我的头顶部...



你会更可能需要处理OnCancelEdit以及并启用在命令栏中的取消按钮


How can I do editable GridView Template Cells TextBox?

解决方案

  1. Use a command column and set ShowEditButton="True" EditText="Edit" ButtonType="Link"
  2. In your template column use the ItemTemplate to describe what the columns should look like in non-edit mode using <asp:Label runat="server" id="txtMyLabel" text='<%# Eval("MyFieldToDisplay") %>' />
  3. Use the EditTemplate of your column to display your edit control. ex. <asp:TextBox runat="server" id="txtMyFieldToEdit" text='<%# Eval("MyFieldToEdit") %>' />
  4. Handle the GridView.OnEditing event as such

    protected void myGridView_OnEditing(object sender, GridViewEditingEventArgs e) { myGridView.EditIndex=e.RowIndex; }

I believe these are the right property/attribute names, but I'm typing off the top of my head...

you'll more than likely need to handle OnCancelEdit as well and enable the cancel button in your command column.

这篇关于我该怎么办编辑的GridView控件模板细胞的TextBox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆