Click here to Skip to main content
15,936,122 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
<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

C#
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);
}


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
Posted
Updated 24-Apr-13 20:08pm
v4

1 solution

SQL
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900