在Gridview asp.net vb中按下编辑时,行未在编辑模式下打开 [英] Row not opening in edit mode on pressing edit in Gridview asp.net vb

查看:73
本文介绍了在Gridview asp.net vb中按下编辑时,行未在编辑模式下打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我在Web应用程序中创建了一个数据绑定网格视图,并试图在每行的编辑按钮中编辑行。但是在按下编辑按钮时,行仍在修复并且不允许编辑。虽然出现了更新和取消按钮。



以下代码为vb

hi all,

I have created a databound grid view in a web application and trying to edit the rows throught each row's edit button. But on pressing the edit button the row is still fix and edit is not allowed. Though the Update and cancel button appears.

following is code in vb

Protected Sub DataGridView1_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles DataGridView1.RowEditing
        DataGridView1.EditIndex = e.NewEditIndex
        Call fnShowBom()***(function to call data from sql and bind the grid)

    End Sub





提前致谢



gridview代码:



Thanks in advance

gridview code:

<asp:GridView ID="DataGridView1"

       runat="server"

       AutoGenerateColumns="false"

       DataKeyNames="BOMIC"

       showfooter="true"

       enablesorting="true"

       CssClass="Grid"

       AllowSorting="True"

       BorderStyle="Groove"

       onrowcancellingedit="datagridview1_rowcancellingedit"

       onrowdatabound="DataGridView1_RowDataBound"

       onrowediting="DataGridView1_RowEditing"

       onrowupdating="DataGridView1_RowUpdating"

       onrowcommand="DataGridview1_Rowcommand"

       onrowdeleting="DataGridView1_RowDeleting"

       onselectedindexchanged="DataGridView1_SelectedIndexChanged"

       >
      <HeaderStyle CssClass="GridHeader" />
       <RowStyle CssClass="GridItem" />
       <AlternatingRowStyle CssClass="GridAltItem" />

       <Columns>
           <asp:TemplateField HeaderText="Item Code"  HeaderStyle-HorizontalAlign="Left">
               <EditItemTemplate>
                   <asp:Label ID="BOMIC" runat="server" Text='<%# Bind("BOMIC")%>'></asp:Label>
               </EditItemTemplate>
               <ItemTemplate>
                   <asp:Label ID="BOMIC" runat="server" Text='<%# Bind("BOMIC") %>'></asp:Label>
               </ItemTemplate>
           </asp:TemplateField>

            <asp:TemplateField HeaderText="Description"  HeaderStyle-HorizontalAlign="Center">
               <EditItemTemplate>
                   <asp:Label ID="BOMIN" runat="server" Text='<%# Bind("BOMIN")%>'></asp:Label>
               </EditItemTemplate>
               <ItemTemplate>
                   <asp:Label ID="BOMIN" runat="server" Text='<%# Bind("BOMIN") %>'></asp:Label>
               </ItemTemplate>
           </asp:TemplateField>

           <asp:TemplateField HeaderText="Qty"  HeaderStyle-HorizontalAlign="Center">
               <EditItemTemplate>
                   <asp:Label ID="BOMIQ" runat="server" Text='<%# Bind("BOMIQ")%>'></asp:Label>
               </EditItemTemplate>
               <ItemTemplate>
                   <asp:Label ID="BOMIQ" runat="server" Text='<%# Bind("BOMIQ")%>'></asp:Label>
               </ItemTemplate>
           </asp:TemplateField>

           <asp:TemplateField HeaderText="Vendor"  HeaderStyle-HorizontalAlign="Center">
               <EditItemTemplate>
                   <asp:Label ID="BOMIV" runat="server" Text='<%# Bind("BOMIV")%>'></asp:Label>
               </EditItemTemplate>
               <ItemTemplate>
                   <asp:Label ID="BOMIV" runat="server" Text='<%# Bind("BOMIV")%>'></asp:Label>
               </ItemTemplate>
           </asp:TemplateField>


           <asp:TemplateField HeaderText="Page No."  HeaderStyle-HorizontalAlign="Center">
               <EditItemTemplate>
                   <asp:Label ID="BOMIRM" runat="server" Text='<%# Bind("BOMIRM")%>'></asp:Label>
               </EditItemTemplate>
               <ItemTemplate>
                   <asp:Label ID="BOMIRM" runat="server" Text='<%# Bind("BOMIRM")%>'></asp:Label>
               </ItemTemplate>
           </asp:TemplateField>

           <asp:TemplateField HeaderText="Edit" ShowHeader="False" HeaderStyle-HorizontalAlign="Left">
               <EditItemTemplate>
                   <asp:LinkButton ID="lnkUpdate" runat="server" CausesValidation="True" CommandName="Update" Text="Update"></asp:LinkButton>
                   <asp:LinkButton ID="lnkCancel" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
               </EditItemTemplate>
               <FooterTemplate>
                   <asp:LinkButton ID="lnkAdd" runat="server" CausesValidation="False" CommandName="Insert" Text="Insert"></asp:LinkButton>
               </FooterTemplate>
               <ItemTemplate>
                   <asp:LinkButton ID="lnkEdit" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit"></asp:LinkButton>
               </ItemTemplate>
           </asp:TemplateField>

           <asp:CommandField HeaderText="Delete" ShowDeleteButton="True" ShowHeader="True" />


      </Columns>

   </asp:GridView>

推荐答案

Hello ,

to get Gridview in Edit mode you have to use TemplateField .and you must use asp:TextBox in the EditItemTemplate instead of asp:Label . For more details

Refer: Simple Insert-Select-Edit-Update in Asp.net Gridview

thanks
Hello ,
to get Gridview in Edit mode you have to use TemplateField .and you must use asp:TextBox in the EditItemTemplate instead of asp:Label . For more details
Refer: Simple Insert-Select-Edit-Update in Asp.net Gridview
thanks


这篇关于在Gridview asp.net vb中按下编辑时,行未在编辑模式下打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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