PostBack!

  • Thread starter Thread starter rcoco
  • Start date Start date
R

rcoco

Hi there! Happy new year.
I'm having this problem with my datagrid, When I scroll to update a
Value, I press edit But it scrolls back itself up. How can I keep it in
one position When I'm Editing? I mean Even when I want t Edit the 100th
Column.
 
I dont have the code to hand, but essentially, you need to create anchor
tags in the html for each row. Use the IDataBound event to create column/row
values ( You will need to add a colum for this ), and in the update event,
you need to create javascript onLoad event to set the locatuion to the
anchor being edited so that when the client page is loaded, it jumps to the
correct place.

Make Sense ?

HTH
 
Thank you very much,

I don't know If we talking the same or I mayed have not got what you
trying to explain to me. But it like this if the user whats to update a
column that is like 50th on the table, he will scroll down get the
column and when he presses edit, the dropdownlist will come properly
but it Scrolls back to the beginning of the table. So the user will
have again have to scroll again down to Be able to update wich is not
what I want. I actually want when the user presses edit the Data grid
should remain intact I mean not to moove. Hope you'll Understand my
problem.
Thank you very much
 
I didnt realize that in .NET 2.0 you could do this with

MaintainScrollPositionOnPostback="true" in the page declaration.

However, this is not supported in 1.x ( dont know if you are using this )
but if you are one approach that I have used ( and there may be more ).

1.) Add a column to your datagrid
2.) In the ItemDataBount Event ( which fired for each row bound to the
grid ) add the an HTML acnchor tag with the number associated with the row
being added.


If e.Item.ItemType <> ListItemType.Footer And e.Item.ItemType <>
ListItemType.Header Then

Dim anchor As New LiteralControl

anchor.Text = "<a name=""" + e.Item.ItemIndex.ToString + """>"

e.Item.Cells(e.Item.Cells.Count - 'YourColumnNumber' ).Controls.Add(anchor)

End If


3.) On Postback when you edit a row, you should intercept the Update event
and call this

bookmarkIndex = e.Item.ItemIndex '// bookmark is a class level integer

InsertScriptBlock

// Sub Further down

Private Sub InsertScriptBlock()

Dim jScript As New System.Text.StringBuilder

jScript.Append("<script language=""JavaScript"">")

jScript.Append("location.href=""#")

jScript.Append(bookmarkIndex.ToString())

jScript.Append(""";")

jScript.Append("</script>")

RegisterClientScriptBlock("Bookmark", jScript.ToString())

End Sub
 
Goofy said:
I didnt realize that in .NET 2.0 you could do this with

MaintainScrollPositionOnPostback="true" in the page declaration.

However, this is not supported in 1.x ( dont know if you are using this )
but if you are one approach that I have used ( and there may be more ).

1.) Add a column to your datagrid
2.) In the ItemDataBount Event ( which fired for each row bound to the
grid ) add the an HTML acnchor tag with the number associated with the row
being added.


If e.Item.ItemType <> ListItemType.Footer And e.Item.ItemType <>
ListItemType.Header Then

Dim anchor As New LiteralControl

anchor.Text = "<a name=""" + e.Item.ItemIndex.ToString + """>"

e.Item.Cells(e.Item.Cells.Count - 'YourColumnNumber' ).Controls.Add(anchor)

End If


3.) On Postback when you edit a row, you should intercept the Update event
and call this

bookmarkIndex = e.Item.ItemIndex '// bookmark is a class level integer

InsertScriptBlock

// Sub Further down

Private Sub InsertScriptBlock()

Dim jScript As New System.Text.StringBuilder

jScript.Append("<script language=""JavaScript"">")

jScript.Append("location.href=""#")

jScript.Append(bookmarkIndex.ToString())

jScript.Append(""";")

jScript.Append("</script>")

RegisterClientScriptBlock("Bookmark", jScript.ToString())

End Sub
In 1.x there is an attribute to the page called 'Smart navigation' which
has been depreciated in 2.0. It didnt work too well and only worked on IE.

Joe (MCAD)
 
Back
Top