Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using a grid view with a check box inside update panel . it is working perfectly. but the problem is when the check box is selected the scroll is going up. the scroll is inside the grid not for the page. i just want to maintain the scroll position inside grid and also get some value after selecting the grid. after post back the scroll going up . how i can solve this.. Thank you


I tried this

What I have tried:

<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="Scripts/ScrollableGridViewPlugin_ASP.NetAJAXmin.js" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function () {
$('#<%=grvBCLList.ClientID %>').Scrollable({
ScrollHeight:300,
IsInUpdatePanel: true

});
});
</script>



<asp:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Release">



<asp:UpdatePanel ID="UpdatePanel1" runat="server">

<contenttemplate>


<%--
--%>


<asp:GridView ID="grvBCLList" runat="server" Height="60px" Width="1600px"
AutoGenerateColumns="False" CellPadding="4" CssClass="style31"
ForeColor="#333333" GridLines="None">
<alternatingrowstyle backcolor="White">
<columns> <asp:BoundField DataField="sTranNo" HeaderText="PRCN Number" SortExpression="sTranNo" />
<asp:BoundField DataField="rcpno" HeaderText="RMS-Rcptno" SortExpression="rcpno" />
<asp:BoundField DataField="dtDateTime" HeaderText="PRCN Date" DataFormatString="{0:d}" SortExpression="dtDateTime" />
<asp:BoundField DataField="sVendorID" HeaderText="Farmer NRC Number" SortExpression="sVendorID" />
<asp:BoundField DataField="sVendorName" HeaderText="Farmer Name"
HeaderStyle-Width="150px" SortExpression="sVendorName" >
<HeaderStyle Width="150px"></HeaderStyle>

<asp:BoundField DataField="sLoc" HeaderText="Satalite Depot" SortExpression="sLoc" />
<asp:BoundField DataField="sItemNo" HeaderText=" Crop Code "
HeaderStyle-Width="100px" SortExpression="sItemNo" >
<HeaderStyle Width="100px"></HeaderStyle>

<asp:BoundField DataField="sItemDescr" HeaderText="Crop Name"
HeaderStyle-Width="200px" SortExpression="sItemDescr" >
<HeaderStyle Width="200px"></HeaderStyle>

<asp:BoundField DataField="sUOM" HeaderText="Unit" SortExpression="sUOM" />
<asp:BoundField DataField="dUnitCost" HeaderText="Item Price" SortExpression="dUnitCost" />
<asp:BoundField DataField="dQtyReceivedActual" HeaderText="Bags Received" SortExpression="dQtyReceivedActual" />
<asp:BoundField DataField="dDocTotal" HeaderText="Crop Value" SortExpression="dDocTotal" />
<asp:TemplateField HeaderText="Verified">
<%-- <edititemtemplate>
<asp:CheckBox ID="chkSelect" runat="server" OnCheckedChanged="ChkSelect_Changed" AutoPostBack="true" />
--%>
<itemtemplate>
<asp:CheckBox ID="cbVerified" runat="server" AutoPostBack="true"
oncheckedchanged="cbVerified_CheckedChanged"/>




<editrowstyle backcolor="#7C6F57">
<footerstyle backcolor="#1C5E55" font-bold="True" forecolor="White">
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<pagerstyle backcolor="#666666" forecolor="White" horizontalalign="Center">
<rowstyle backcolor="#E3EAEB">
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<sortedascendingcellstyle backcolor="#F8FAFA">
<sortedascendingheaderstyle backcolor="#246B61">
<sorteddescendingcellstyle backcolor="#D4DFE1">
<sorteddescendingheaderstyle backcolor="#15524A">




<asp:TextBox ID="txtSelPCRNTotal" runat="server" Enabled="false" style="text-align:right">
<%--
--%><%--
--%>

<asp:Label ID="lbl_test" runat="server">

Posted
Updated 15-May-16 20:22pm
Comments
Karthik_Mahalingam 14-May-16 6:27am    
are you rebinding the data in ChkSelect_Changed event
Member 11165428 15-May-16 3:17am    
protected void cbVerified_CheckedChanged(object sender, EventArgs e)

{


int iSum = 0;
foreach (GridViewRow row in grvBCLList.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
CheckBox chkRow = (CheckBox)row.Cells[0].FindControl("cbVerified");

if (chkRow.Checked)
{
iSum = iSum + int.Parse(grvBCLList.Rows[row.DataItemIndex].Cells[11].Text.ToString());
lbl_test.Text = iSum.ToString();
}

txtSelPCRNTotal.Text = iSum.ToString();
//try
//{
// txtBalance.Text = (int.Parse(txtTotalPRCN.Text) - iSum).ToString();
// if (!CheckTheBudgetLimit(iSum))
// {
// // chkRow.Checked = false;
// litBudgetError.Visible = true;
// Process.Enabled = false;
// txtSelPCRNTotal.Text = (iSum - (int.Parse(grvBCLList.Rows[row.DataItemIndex].Cells[10].Text.ToString()))).ToString();
// txtBalance.Text = (int.Parse(txtTotalPRCN.Text) - iSum - (int.Parse(grvBCLList.Rows[row.DataItemIndex].Cells[10].Text.ToString()))).ToString();
// }
// else
// {
// litBudgetError.Visible = false;
// Process.Enabled = true;
// }
//}
//catch (Exception ex) { }
}
}

Member 11165428 15-May-16 3:20am    
chkselect_changed is not using here.. using only the next check box id.. cbvarified_checkedchanged()
Karthik_Mahalingam 15-May-16 3:33am    
OkYou have to capture the scroll position in js on client side check change event
Member 11165428 16-May-16 2:04am    
yes... u r right

1 solution

use scrollTop [^] to capture the scroll bar position before doing the post back and save it temporarily in a hidden field,
once the postback is happened and using Jquery load function at the last part of your script
JavaScript
<script>
      $(function () {
          var div = document.getElementById('Your Scroll bar Container id');
          div.scrollTop = document.getElementById('hiddenFieldID').value;
      });
  </script>


Saving the Scroll position before postback is done using Client side click event of the checkbox
refer javascript - Getting value of HTML Checkbox from onclick/onchange events [^]
 
Share this answer
 
Comments
Member 11165428 19-May-16 4:46am    
its not working still now

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