我有一個gridview有兩列名稱和地址和一個保存按鈕。 它是一個自動生成的列網格。編輯gridview單元格的文本框?
<asp:GridView ID="gvStandardSummary" runat="server" HeaderStyle-CssClass="columnheaderLightBlue"
AlternatingRowStyle-CssClass="infoarea" Width="100%" AutoGenerateColumns="true"
AllowPaging="true" PageSize="20" OnPageIndexChanging="gvStandardSummary_PageIndexChanged"
OnRowDataBound="gvStandardSummary_OnRowDataBound" EmptyDataText="No work items to display."
EmptyDataRowStyle-CssClass="infoarea" OnRowCommand="gvStaffingPlan_RowCommand">
</asp:GridView>
我不能使用Item模板。我只需要對地址列進行內聯編輯。
當我在地址欄中單擊它會變成可編輯的...我將編輯...然後單擊第二個記錄的地址編輯...最後保存..
在保存它應該更新數據庫,並刷新。我不能使用項目templete,不得不在Rowdaabound添加文本框......但nneed精確解...任何幫助
行數據boung我添加一個文本框
TextBox txtAddress = new TextBox();
txtAddress.ReadOnly = false;
e.Row.Cells[1].Controls.Add(txtAddress);
e.Row.Cells[1].Style.Add("text-align", "center");
這裏怎麼能我自動適應它在細胞...並使其可編輯
,因爲我不是在這裏使用包裝紙
for (int i = 0; i < e.Row.Cells.Count; i++)
{
e.Row.Cells[i].Attributes.Add("style", "white-space:nowrap;");
}
列應擴大和基於文本崩潰 txtpkgNumber.Text = e.Row.Cells [0]。文本;
你能否提供更多的細節?您是否使用默認的ASP.NET Grid View編輯,即一次只能進行一次行編輯?或者你是否試圖通過單擊按鈕來編輯所有行? – Nunners
@Nunners它的一行編輯在一次time.Normal ASP.net Gridviw ...在這裏我可以在Rowdatabound中添加一個文本框...但需要自動適應單元格中的文本框.. –
是否有一個特定的原因爲什麼你需要在RowDataBound方法中添加文本框?你究竟遇到了什麼困難?更新? TextBox被添加? – Nunners