Hello,
i use a RadGrid in a UpdatePanel. The cells contain ImageButtons.
Code:
When I click a ImageButton, then the grid in the UpdatePanel is refreshed.
How can I automatically scroll back to the current row/column (ImageButton) after the refresh?
Reiner
i use a RadGrid in a UpdatePanel. The cells contain ImageButtons.
<
asp:UpdatePanel
ID
=
"UpdatePanel1"
runat
=
"server"
>
<
ContentTemplate
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
Width
=
"900px"
Height
=
"400px"
Skin
=
"Office2007"
onitemdatabound
=
"RadGrid1_ItemDataBound"
onitemcommand
=
"RadGrid1_ItemCommand"
GridLines
=
"None"
>
<
ClientSettings
>
<
Scrolling
AllowScroll
=
"true"
UseStaticHeaders
=
"true"
FrozenColumnsCount
=
"1"
SaveScrollPosition
=
"true"
/>
</
ClientSettings
>
<
MasterTableView
TableLayout
=
"Auto"
/>
<
HeaderStyle
Width
=
"100px"
/>
</
telerik:RadGrid
>
</
ContentTemplate
>
<
Triggers
>
<
asp:AsyncPostBackTrigger
ControlID
=
"RadGrid1"
EventName
=
"ItemCommand"
/>
</
Triggers
>
</
asp:UpdatePanel
>
Code:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
Label lbl = new Label();
lbl.Text = item[""].Text.Substring(item[""].Text.IndexOf("|") + 1);
item[""].Controls.Add(lbl);
for (int i = 0; i < gruppenliste.Count; i++)
{
ImageButton imgbtn = new ImageButton();
if (item[gruppenliste[i].ToString()].Text.StartsWith("0"))
{
imgbtn.CommandName = "add";
imgbtn.ImageUrl = "../img/cancel.gif";
item[gruppenliste[i].ToString()].Controls.Add(imgbtn);
item[gruppenliste[i].ToString()].HorizontalAlign = HorizontalAlign.Center;
imgbtn.CommandArgument = item[""].Text.Substring(
0, item[""].Text.IndexOf("|")) +
"|" +
item[gruppenliste[i].ToString()].Text.Substring(
item[gruppenliste[i].ToString()].Text.IndexOf("|") + 1);
}
else
{
imgbtn.CommandName = "del";
imgbtn.ImageUrl = "../img/ok.gif";
item[gruppenliste[i].ToString()].Controls.Add(imgbtn);
item[gruppenliste[i].ToString()].HorizontalAlign = HorizontalAlign.Center;
imgbtn.CommandArgument = item[""].Text.Substring(
0, item[""].Text.IndexOf("|")) +
"|" +
item[gruppenliste[i].ToString()].Text.Substring(
item[gruppenliste[i].ToString()].Text.IndexOf("|") + 1);
}
}
}
}
When I click a ImageButton, then the grid in the UpdatePanel is refreshed.
How can I automatically scroll back to the current row/column (ImageButton) after the refresh?
Reiner