我有一個gridview中包含文本框作爲模板field.The網格視圖存在更新面板中。我的問題是:
當文本更改事件已經觸發時,感覺像瀏覽器的jump
類似於(回發)的行爲。 但它不是回發。我不知道爲什麼會發生這種奇怪的行爲。
我的aspx:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="pnl_research" runat="server" CssClass="pnl">
<div id="detailsDiv" align="center" style="width: 800px;">
<table border="0" width="98%">
<tr>
<td align="center">
<div class="grid" dir="rtl">
<div class="grid" dir="rtl">
<div class="rounded">
<div class="top-outer">
<div class="top-inner">
<div class="top">
<h2>
<asp:Label ID="Label35" runat="server" Text="جدول التقييم العام"></asp:Label></h2>
</div>
</div>
</div>
<div class="mid-outer">
<div class="mid-inner">
<div class="mid">
<asp:GridView Width="100%" ID="gv_Evaluation" CssClass="datatable" AllowSorting="True"
runat="server" AutoGenerateColumns="False" AllowPaging="True" GridLines="None"
OnRowDataBound="gv_Evaluation_RowDataBound">
<EmptyDataTemplate>
<table style="width: 100%;">
<tr>
<td>
</tr>
<tr>
<td align="center">
<asp:Label ID="Label4" runat="server" Font-Size="16pt" Text="لا يوجد بيانات"></asp:Label>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</EmptyDataTemplate>
<Columns>
<asp:TemplateField HeaderText="م">
<ItemTemplate>
<asp:Label ID="lblSerial" runat="server"></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="نوعية النشاط" DataField="activityType" />
<asp:BoundField HeaderText="أوزان النشاط" DataField="activityWeight" />
<asp:TemplateField HeaderText="التقييم">
<ItemTemplate>
<telerik:RadTextBox ID="txt_evaluateWeights" runat="server" AutoPostBack="True" OnTextChanged="txt_evaluateWeights_TextChanged"
hideData='<%#((GridViewRow)Container).RowIndex%>'>
</telerik:RadTextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txt_evaluateWeights"
Display="Dynamic" ErrorMessage="*" SetFocusOnError="True"></asp:RequiredFieldValidator></ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="التقييم الذاتي" DataField="activitySelf" />
<asp:BoundField HeaderText="تقييم رئيس القسم" DataField="activityBoss" />
<asp:BoundField HeaderText="تقييم العميد" DataField="activityDean" />
</Columns>
<RowStyle VerticalAlign="Top" CssClass="row" />
</asp:GridView>
</div>
</div>
</div>
<div class="bottom-outer">
<div class="bottom-inner">
<div class="bottom">
</div>
</div>
</div>
</div>
</div>
</div>
</td>
</tr>
</table>
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
編輯:
我刪除
此行hideData='<%#((GridViewRow)Container).RowIndex%>'
protected void txt_evaluateWeights_TextChanged(object sender, EventArgs e)
{
calc();
int index = ((System.Web.UI.WebControls.GridViewRow)(((RadTextBox)sender).Parent.NamingContainer)).DataItemIndex;
//int index = int.Parse(((RadTextBox)sender).Attributes["hideData"]);
((RadTextBox)gv_Evaluation.Rows[index + 1].Cells[3].FindControl("txt_evaluateWeights")).Focus();
}
仍然是同樣的問題!
EDIT2:
protected void gv_Evaluation_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblSerial = (Label)e.Row.FindControl("lblSerial");
lblSerial.Text = ((gv_Evaluation.PageIndex * gv_Evaluation.PageSize) + e.Row.RowIndex + 1).ToString();
RadTextBox txt = e.Row.FindControl("txt_evaluateWeights") as RadTextBox;
ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(txt);
}
}
還是同樣的問題!
EDIT3:
我知道這個問題,但我不知道如何解決它:
問題是此行的結果:
((RadTextBox)gv_Evaluation.Rows[index + 1].Cells[3].FindControl("txt_evaluateWeights")).Focus();
但我需要這行代碼。如何防止Focus()
方法跳轉到頁面頂部。
請,任何幫助解決我的問題 –
我編輯我的問題 –