i have 2 web datagrids that are in a master detail relationship. I currently highlight the most relevant record in the child grid but have been unable to scroll it programatically into view if it is not currenlly visible. I have used selected row to highlight the field and have also set active row to the same field. however, i still have to scroll manually to the highlighted record. How can i get the row that is selected and active to also be visible. tks. i am using VB codebehind to do all of this.
Any additional info on how to calculate the toprow value? Espeically , how to get row height(s) in code behind to help in accurately positioning the scrollbar?
Almost there, however, you have once again used an unexplained number... where did the number 30 come from. It does need adjustment of some sort depending on the data content of the grid and i have no idea where that number came from. I am guessing that is some value for a row- height. As demonstrated it works at times and at others the position is off a bit and the selected row does not appear on screen. But the result is getting there. Thanks again for your help.
Hello,
Let say that we have a grid with 100 rows and we want to set the 60-th row as selected and we want to show it in grid view on postback.
You can do something like this in server code:
protected void Button1_Click(object sender, EventArgs e)
{
//Select a row
WebDataGrid1.Behaviors.Selection.SelectedRows.Add(
WebDataGrid1.Rows[60]);
//Get the index of the selected row.
int selectedRowIndex =
WebDataGrid1.Behaviors.Selection.SelectedRows[0].Index;
int result = 30 * selectedRowIndex;
//Scroll the grid
WebDataGrid1.ScrollTop = result;
}
Hope this helps.
Hello Radoslav,
I can set the scroll top property and position the the bar. However, how do you calculate the correct value for scrolltop. I have tried different scenarios for calculating the value but cannot find a source that will allow me to calculate an effective value. As i said i am trying to position to the currently active or select row.
Best Regards
Hello Garry,
Let me know if you have any questions with this?
Thanks.