When you click edit button on the gridview, the row is selected and you are able to update values in a textbox. The scrollbar shows the selected row and does not move towards the beginning of the web page, however around half way of the gridview, if you click on edit then it jumps a few rows down and you have to scroll up to go to the selected row to edit. When you edit the second to last row, it jumps all the way up and you have to scroll down. For some reason its not keeping the scroll position.
I tried to use in my edit grid view method :
gvCaseList.FirstDisplayedScrollingRowIndex = e.NewEditIndex;
but its bringing back an error:
> 'System.Web.UI.WebControls.GridView' does not contain a definition for
> 'FirstDisplayedScrollingRowIndex' and no extension method
> 'FirstDisplayedScrollingRowIndex' accepting a first argument of type
> 'System.Web.UI.WebControls.GridView' could be found (are you missing a
> using directive or an assembly reference?
The edit method is as follows:
//When edit is selected, allows user to update textbox and drop down
protected void gvCaseList_edit(object sender, GridViewEditEventArgs e)
{
EditClicked = true;
Label label1 = (Label)gvCaseList.Rows[e.NewEditIndex].FindControl("Label1");
CurrentException = label1.Text;
gvCaseList.EditIndex = e.NewEditIndex;
if (ViewState["dirState"] != null)
{
gvCaseList.DataSource = ViewState["dirState"];
gvCaseList.DataBind();
}
else
{
GetgvSearchCaseListData();
}
}
How can i make sure on edit, the row being edited is shown on the browser and it stops scrolling to a different part on the page?
I have the gridview wrapped around an update panel in my aspx code:
<asp:updatepanel runat="server">
<ContentTemplate>
<asp:GridView ID="gvCaseList" runat="server" AllowSorting="True" OnSorting="gvCaseList_Sorting" OnRowEditing="gvCaseList_edit" OnRowUpdating="gvCaseList_RowUpdating" OnRowCancelingEdit="gvCaseList_RowCancelingEdit" OnRowDataBound="gvCaseList_RowDataBound" CellPadding="4" GridLines="Horizontal" AutoGenerateColumns="False" BackColor="White" BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" >
<AlternatingRowStyle BackColor="Silver" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="EditButton" CssClass="btn btn-primary dropdown-toggle" runat="server" Text="Edit" CommandName="Edit" ></asp:Button>
</ItemTemplate>
<EditItemTemplate>
<asp:Button ID="UpdateButton" CssClass="btn btn-primary dropdown-toggle" runat="server" Text="Update" CommandName="Update" ></asp:Button>
<asp:Button ID="CancelButton" CssClass="btn btn-primary dropdown-toggle" runat="server" Text="Cancel" CommandName="Cancel"></asp:Button>
</EditItemTemplate>
<ControlStyle Width="100px" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:updatepanel>