当前位置: 代码迷 >> ASP.NET >> 重新开贴,gridview有关问题,求解,求实例,求大侠,
  详细解决方案

重新开贴,gridview有关问题,求解,求实例,求大侠,

热度:2332   发布时间:2013-02-25 00:00:00.0
重新开贴,gridview问题,,求解,,,,急,在线等,求实例,求大侠,,,,
gridview 两个编辑按钮,六个字段,点击按钮A,1、2、3列为编辑状态4、5、6为非编辑状态,点击按钮B,4、5、6为编辑状态1、2、3为非编辑状态,请问这样的效果怎么实现呢?


------解决方案--------------------------------------------------------
采用模板列,可以随便加按钮
------解决方案--------------------------------------------------------
探讨

采用模板列,可以随便加按钮

------解决方案--------------------------------------------------------
HTML code
 <asp:GridView ID="Grv_Company" runat="server" AutoGenerateColumns="False" CellPadding="4"                                        ForeColor="#333333" OnRowEditing="Grv_Company_RowEditing" OnRowUpdating="Grv_Company_RowUpdating"                                        OnRowCancelingEdit="Grv_Company_RowCancelingEdit" OnRowCommand="Grv_Company_RowCommand"                                        Width="600px">                                        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />                                        <RowStyle BackColor="#EFF3FB" />                                        <Columns>                                            <asp:TemplateField HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center"                                                ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle">                                                <HeaderTemplate>                                                    Action                                                </HeaderTemplate>                                                <ItemTemplate>                                                    <asp:LinkButton Text="<img src='../images/edit.gif' border=0>" CommandName="edit"                                                        runat="Server" ID="Linkbutton1" />                                                </ItemTemplate>                                                <EditItemTemplate>                                                    <asp:LinkButton Text="<img src='../images/update.gif' border=0>" CommandName="update"                                                        runat="Server" ID="Linkbutton2" />                                                    <asp:LinkButton Text="<img src='../images/cancel.gif' border=0>" CommandName="cancel"                                                        runat="Server" ID="Linkbutton3" />                                                </EditItemTemplate>                                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />                                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />                                            </asp:TemplateField>                                            <asp:TemplateField HeaderText="Company Name" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center"                                                ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle">                                                <ItemTemplate>                                                    <asp:Label ID="lbl_Name" runat="server" Text='<%#Eval("CompanyName")%>'></asp:Label>                                                </ItemTemplate>                                                <EditItemTemplate>                                                    <asp:TextBox ID="txt_Name" runat="server" Text='<%#Eval("CompanyName")%>' Width="95%"></asp:TextBox>                                                </EditItemTemplate>                                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />                                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />                                            </asp:TemplateField>                                            <asp:TemplateField HeaderText="CompanyID" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center"                                                ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle">                                                <ItemTemplate>                                                    <asp:Label ID="lbl_ID" runat="server" Text='<%# Bind("CompanyID")%>'></asp:Label>                                                </ItemTemplate>                                                <EditItemTemplate>                                                    <asp:Label ID="lbl_ID_Edit" runat="server" Text='<%# Bind("CompanyID") %>'></asp:Label>                                                </EditItemTemplate>                                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />                                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />                                            </asp:TemplateField>                                            <asp:TemplateField HeaderText="CompanyCode" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center"                                                ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle">                                                <ItemTemplate>                                                    <asp:Label ID="lbl_Code" runat="server" Text='<%# Bind("CompanyCode")%>'></asp:Label>                                                </ItemTemplate>                                                <EditItemTemplate>                                                    <asp:TextBox ID="txt_Code" runat="server" Text='<%#Eval("CompanyCode")%>' Width="95%"></asp:TextBox>                                                </EditItemTemplate>                                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />                                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />                                            </asp:TemplateField>                                        </Columns>                                        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />                                        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />                                        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />                                        <EditRowStyle BackColor="#2461BF" />                                        <AlternatingRowStyle BackColor="White" />                                    </asp:GridView>