or
| map = new GMap2(document.getElementById("map_canvas")); |
| map.setCenter(new GLatLng(42.351505,-71.094455), 15); |
| directionsPanel = document.getElementById("route"); |
| directions = new GDirections(map, directionsPanel); |
| directions.load("500 Memorial Drive, Cambridge, MA to 4 Yawkey Way, Boston, MA 02215 (Fenway Park)"); |
When a user selects a row on my grid and clicks the button, it is meant to update the value of one of the columns by inserting a string to the database based on the selection.
However, the button causes a postback so the state of the grid's selected row value is lost.
My parameter comes back with an out of bounds error despite the grid looking checked on the running form:
ClientId.Value = grdClient.SelectedItems(0).OwnerTableView.DataKeyValues(grdClient.SelectedItems(0).ItemIndex)("iClientId")
How can I preserve the selected state of the grid so the client id selected value can be passed to the parameter after the button's postback?
| protected void Grid_ItemDataBound(object sender, GridItemEventArgs e) |
| { |
| if (e.Item is GridEditableItem && e.Item.IsInEditMode) |
| { |
| GridEditableItem item = e.Item as GridEditableItem; |
| CheckBox cb = (CheckBox)item["Toggler"].Controls[0]; |
| cb.AutoPostBack = true; |
| } |
| } |
| protected void Grid_PreRender(object sender, System.EventArgs e) |
| { |
| foreach (GridEditFormItem item in rgrdList.MasterTableView.GetItems(GridItemType.EditFormItem)) |
| { |
| if (item.IsInEditMode) |
| { |
| bool isToggled = ((CheckBox)item["Toggler"].Controls[0]).Checked; |
| ((TextBox)item["TextItem1"].Controls[0]).Enabled = isToggled; |
| ((TextBox)item["TextItem2"].Controls[0]).Enabled = isToggled; |
| ((TextBox)item["TextItem3"].Controls[0]).Enabled = isToggled; |
| } |
| } |
| } |