不确定这是否是一个奇怪的,但我有一个在行编辑时消失的网格视图,
我的步骤是>单击butUsers>单击编辑>网格消失>单击butDev>网格返回>单击ButUsers>网格加载我在编辑模式中选择的项目。
我的活动缺少什么?
谢谢
代码隐藏
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class equipment : System.Web.UI.Page
{
public string strMode;
ParameterCollection pcEquip;
dsData.tblEquipmentDataTable dtEquipment;
dsDataTableAdapters.tblEquipmentTableAdapter taEquipment;
SqlDataSource dsEquipment;
protected void Page_Load(object sender, EventArgs e)
{
dtEquipment = new dsData.tblEquipmentDataTable();
taEquipment = new dsDataTableAdapters.tblEquipmentTableAdapter();
dsEquipment = new SqlDataSource();
smEquipment.RegisterAsyncPostBackControl(butUsers);
}
protected void butUsers_Click(object sender, EventArgs e)
{
hidMode.Value = "Users";
dtEquipment.Clear();
taEquipment.FillByUsers(dtEquipment);
gvItems.DataSource = dtEquipment;
gvItems.DataBind();
upTable.Update();
}
protected void butDevelopment_Click(object sender, EventArgs e)
{
//hidMode.Value = "Users";
dtEquipment.Clear();
taEquipment.FillByDev(dtEquipment);
gvItems.DataSource = dtEquipment;
gvItems.DataBind();
upTable.Update();
}
protected void gvItems_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
}
protected void gvItems_RowEditing(object sender, GridViewEditEventArgs e)
{
gvItems.EditIndex = e.NewEditIndex;
gvItems.DataSource = dtEquipment;
gvItems.DataBind();
upTable.Update();
}
}
ASPX 页面
<asp:Content ID="cntCenter" ContentPlaceHolderID="CenterContent" runat="Server">
<asp:UpdatePanel runat="server" ID="upTable" UpdateMode="Conditional">
<ContentTemplate>
<asp:HiddenField runat="server" ID="hidMode" />
<grid:TemplateGridView
EnableTemplateEditing="True"
runat="server" ID="gvItems" OnRowDataBound="gvItems_RowDataBound" OnRowEditing="gvItems_RowEditing"
AutoGenerateColumns="False" DataKeyNames="ID" AllowPaging="True"
AllowSorting="True" CssClass="table" BorderStyle="None" BorderWidth="0px"
GridLines="None">
<Columns>
<asp:CommandField ShowEditButton="True" ShowDeleteButton="True" />
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
ReadOnly="True" SortExpression="ID" Visible="False" />
<asp:BoundField DataField="UserID" HeaderText="UserID"
SortExpression="UserID" Visible="False" />
<asp:BoundField DataField="AssetNo" HeaderText="Asset No"
SortExpression="AssetNo" />
<asp:BoundField DataField="Username" HeaderText="User Name"
SortExpression="Username" />
</Columns>
<EditItemTemplate>
<div class="details">
<asp:HiddenField ID="hidID" runat="server" Value='<%# Eval("ID") %>' />
<asp:HiddenField ID="hidUserID" runat="server" ClientIDMode="Static" Value='<%# Bind("UserID") %>' />
<table class="detailsview" cellpadding="0" cellspacing="0">
<tr>
<td class="td_title_align">Asset No:</td>
<td>
<asp:TextBox ID="txtAssetNo" runat="server" CssClass="edit_box" Text='<%# Bind("AssetNo") %>' />
</td>
<td class="td_title_align">CPU:</td>
<td>
<asp:TextBox ID="txtCPU" runat="server" CssClass="edit_box" Text='<%# Bind("CPU") %>' />
</td>
<td class="td_title_align">Shipped Date:</td>
<td>
<asp:TextBox ID="txtShippedDate" runat="server" CssClass="edit_box" Text='<%# Bind("ShippedDate", "{0:dd/MM/yyyy}") %>' />
</td>
</tr>
<tr>
<td colspan="8">
<div class="footer_command">
<asp:Button runat="server" ID="btnUpdate" CommandName="Update" Text="Update" CssClass="command_button" />
<asp:Button runat="server" ID="btnCancel" CommandName="Cancel" Text="Cancel" CssClass="command_button" />
</div>
</tr>
</table>
</div>
</td>
</tr>
</EditItemTemplate>
</grid:TemplateGridView>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>