单击网格外部的保存按钮后,文本框进入边界字段 [英] Textbox comes in boundfield after clicking save button outside grid
本文介绍了单击网格外部的保存按钮后,文本框进入边界字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<asp:GridView ID="gvFinancialdtls" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataKeyNames="Financial_Year_Id" EmptyDataText="Financial year is empty" EmptyDataRowStyle-HorizontalAlign="Center"
OnPageIndexChanging="gvFinancialdtls_PageIndexChanging" OnRowDeleting="gvFinancialdtls_RowDeleting"
OnRowEditing="gvFinancialdtls_RowEditing" OnSorting="gvFinancialdtls_Sorting"
Width="60%" OnDataBound="gvFinancialdtls_DataBound">
<Columns>
<asp:BoundField DataField="From_Date" HeaderStyle-Width="30%" HeaderText="From Date"
ItemStyle-Width="20%" SortExpression="From_Date" />
<asp:BoundField DataField="To_Date" HeaderStyle-Width="20%" HeaderText="To Date"
ItemStyle-Width="20%" SortExpression="To_Date" />
<asp:BoundField DataField="Notes" HeaderStyle-Width="20%" HeaderText="Notes" ItemStyle-Width="60%"
ControlStyle-Width="20%" />
<asp:CommandField ShowEditButton="True" ButtonType="Link" ControlStyle-CssClass="gvEdit"
EditText="<div>Edit</div>" />
<asp:CommandField ShowDeleteButton="True" ButtonType="Link" ControlStyle-CssClass="gvDelete"
DeleteText="<div>Delete</div>" />
</Columns>
</asp:GridView>
代码落后 - 行编辑
code behind - Row editing
private void BindFinancialeditdtls(int index)
{
string notes;
LblFinancial_Year_Id.Text = gvFinancialdtls.DataKeys[index].Value.ToString();
string fromdate = gvFinancialdtls.Rows[index].Cells[0].Text;
string todate = gvFinancialdtls.Rows[index].Cells[1].Text;
if (gvFinancialdtls.Rows[index].Cells[2].Text.Length > 30)
{
notes = gvFinancialdtls.Rows[index].ToolTip;
}
else
{
notes = gvFinancialdtls.Rows[index].Cells[2].Text;
}
txtCalfromdate.Text = fromdate;
txtCaltodate.Text = todate;
txtRemark.Text = notes;
}
protected void gvFinancialdtls_RowEditing(object sender, GridViewEditEventArgs e)
{
BindFinancialeditdtls(e.NewEditIndex);
}
编辑后,值适用于上面的文本框,但是通过单击网格外的保存按钮保存编辑后的值。编辑的行显示文本框而不是绑定字段,还有名为update&的新按钮。取消了。
如何避免在boundfield& ;;更新&取消编辑行中的按钮。
谢谢
after editing , values applies to above textbox, but after saving the edited value by clicking Save Button outside grid. The edited row displays textbox instead of bound field, also new button named update & cancel are rendered.
how to avoid the textbox rendering in boundfield & update & cancel button in the edited row.
Thanks
推荐答案
we have to give readonly="true" to prevent textbox coming out of boundfield.
Also we shoudld not give any text for EditText="" CancelText=""
DeleteText="" InsertText="" InsertVisible="False" NewText="" SelectText=""
ShowCancelButton="False" UpdateText="" ShowEditButton="True" />
to avoid update button & cancel button
这篇关于单击网格外部的保存按钮后,文本框进入边界字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文