我有一个gridview,目前看起来像这样:
我想使用按钮添加新行来覆盖它上面按钮的2列。
此外,我想在其他4列上添加文本框,并有效地使该行成为“添加用户行”我是初学者并仍在尝试,详细解释将非常有用。
这是html代码:
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="Admin.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link href="css/admin.css" rel="stylesheet" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<header class="grid_9">פאנל מנהל</header>
<div class="grid_9 block_head">
טבלת משתמשים
</div>
<div class="block grid_9" id="user_block" runat="server">
<asp:GridView ID="gdview" OnRowEditing="gdview_RowEditing" DataKeyNames="id" AutoGenerateColumns="False"
CssClass="Grid" OnRowUpdating="gdview_RowUpdating" OnRowCancelingEdit="gdview_RowCancelingEdit"
runat="server" HeaderStyle-CssClass="tableheader" OnRowDeleting="gdview_RowDeleting" OnRowCreated="RowCreated"
ShowFooter="true">
<Columns>
<asp:BoundField HeaderText="מספר מזהה" DataField="id" ReadOnly></asp:BoundField>
<asp:BoundField HeaderText="שם משתמש" DataField="username"></asp:BoundField>
<asp:BoundField HeaderText="סיסמא" DataField="password"></asp:BoundField>
<asp:BoundField HeaderText="אימייל" DataField="email"></asp:BoundField>
<asp:CommandField ShowEditButton="True" CancelText="בטל" UpdateText="עדכן" EditText="ערוך"></asp:CommandField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkdel" runat="server" Text="מחק" CommandName="Delete"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<FooterTemplate>
<asp:Button ID="ButtonAdd" runat="server" Text="Add New Row" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</asp:Content>
谢谢!
答案 0 :(得分:1)
这可能对某人有所帮助。以下链接的解决方案对我有用: https://www.codeproject.com/Answers/544063/HowplustoplusMergepluscellsplusinplusAsp-netplusGr#answer1
链接中的代码段:
#DROP TABLE TT1;
CREATE TABLE TT1 (date datetime);
INSERT INTO TT1 values ('2015-12-31');
INSERT INTO TT1 values ('2016-01-01');
SELECT
date,
CONCAT( DATE_FORMAT(date, "%v") , '-', CASE WHEN DATE_FORMAT(date, "%v")>52 AND DATE_FORMAT(date, "%m")=1 THEN DATE_FORMAT(date, "%Y")-1 ELSE DATE_FORMAT(date, "%Y") END ) AS week
FROM TT1;
DROP TABLE TT1;