ASP的EditTemplate属性:GridView控件 [英] EditTemplate property of asp:GridView control

查看:443
本文介绍了ASP的EditTemplate属性:GridView控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP:GridView和在那里我有两列,一列中我想说明的标签
但是当我点击一个按钮SDIT我想显示一个下拉列表中的特定列,
我创建了网格视图类似以下内容:

I have a asp:GridView and in there i have two columns , in one column i want to show label but when i click an sdit button i want to show a drop down list in that particular column, i have created the grid view like following:

<bw:GridView ID="grdProducts" AllowPaging="True" PageSize="5" AllowSorting="True" 
  CssClass="DGTable" runat="server" AutoGenerateColumns="False" DataKeyNames="LinkedProductCode"
  RowSelectingEnabled="True" RowStyle-CssClass="DGItem" SelectedRowStyle-CssClass="DGSelectedItem"
  FooterStyle-CssClass="DGFooterTR"  EditRowStyle-CssClass="DGEditItemValidator" >
  <Columns>
    <asp:BoundField DataField="LinkedProductCode" HeaderText="Product Code" ReadOnly="true" meta:resourcekey="BoundFieldResource4" />                                        
    <asp:TemplateField  HeaderText="Product Type" ItemStyle-VerticalAlign="Top">
     <ItemTemplate>
     <asp:Label ID="lbl1" runat="server" Text='<%# Bind("LinkedProductType")%>' /> 
    </ItemTemplate>
     <EditItemTemplate >
       <asp:DropDownList ID="linkedproductList" runat="server" DataSourceID="list">
       </asp:DropDownList>
     </EditItemTemplate>
    </asp:TemplateField>                                        
  </Columns>
  <SelectedRowStyle CssClass="DGSelectedItem" />
  <PagerStyle CssClass="DGPagerTR" />
  <HeaderStyle CssClass="DGHeaderTR" />
</bw:GridView>

我应该怎么做呢?我应该在编辑按钮的Click事件写的是什么?
请帮助..

what should i do to do it? What should i write in edit button's click event? Please help..

推荐答案

这要看你是如何设置的编辑按钮。如果你有

It depends on how you are setting up the Edit button. If you have

<asp:Button ID="btnEdit" CommandName="Edit" runat="server" Text="Edit" />

&LT之内; ItemTemplate中&GT; 在GridView,那么在GridView将自动进入编辑模式,单击编辑按钮时。该的CommandName 修改是一个特殊的CommandName把一个GridView进入编辑模式。

within an <ItemTemplate> in the GridView, then the Gridview will automatically go into Edit mode when the Edit button is clicked. The CommandName Edit is a special CommandName to put a GridView into edit mode.

如果你想实现在编辑模式下一些具体的行为,那么这可以通过建立一个OnRowEditing事件处理程序实现,在这里实现自己的逻辑。这将是这个样子

If you wanted to implement some specific behaviour in edit mode, then this can be achieved by setting up an OnRowEditing event handler and implement your logic here. This would look something like this

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
    // Set editing on the row that raised the event
    GridView1.EditIndex = e.NewEditIndex;

    /* Insert specific editing logic here */

    GridView1.DataBind();
}

这篇关于ASP的EditTemplate属性:GridView控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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