The Excel-Like Radgrid code that given by telerik is very useful. I am using the code excellikegrid-updated.zip in my application. It is working fine for the first set of records.
I am using virtual paging in that Excel-like RadGrid solution. For first page, the records displaying as like excel editable mode and we are able to add/Update data in those cells. But when we go to second page using pagination it throws an exception follows.
"Specified argument was out of the range of valid values.
Parameter name: index".
at the line "TextBox textBox = (item[column.UniqueName].Controls[0]) as TextBox;" Inside pre-render event of RadGrid.
At the first time(page load), After "Need Datasource" event, the event "Data Binding" firing and sets all the records in the grid to edit mode.
At the time of postback for Next page, after the event "Need Datasource", the "radGridProducts_DataBinding" event is not firing and it goes to pre-render event; no controls in any item of grig and displays the above error message.
I have tried to set all grid items to editable mode in pre-render event iteself as follows.
But still, it throws the same "Index out of bound" exception while getting the TextBox control.
Any solution for this Issue?
Thanks in Advance.
I am using virtual paging in that Excel-like RadGrid solution. For first page, the records displaying as like excel editable mode and we are able to add/Update data in those cells. But when we go to second page using pagination it throws an exception follows.
"Specified argument was out of the range of valid values.
Parameter name: index".
at the line "TextBox textBox = (item[column.UniqueName].Controls[0]) as TextBox;" Inside pre-render event of RadGrid.
At the first time(page load), After "Need Datasource" event, the event "Data Binding" firing and sets all the records in the grid to edit mode.
protected void radGridProducts_DataBinding(object sender, EventArgs e) { DataTable currentProducts = _presenter.GetCurrentDataTable(); for (int i = 0; i < currentProducts.Rows.Count; i++) //for (int i = 0; i < radGridProducts.VirtualItemCount; i++) { radGridProducts.EditIndexes.Add(i); } }At the time of postback for Next page, after the event "Need Datasource", the "radGridProducts_DataBinding" event is not firing and it goes to pre-render event; no controls in any item of grig and displays the above error message.
I have tried to set all grid items to editable mode in pre-render event iteself as follows.
protected void radGridProducts_PreRender(object sender, EventArgs e) { //Added for Test purpose DataTable currentProducts = _presenter.GetCurrentDataTable(); for (int i = 0; i < currentProducts.Rows.Count; i++) { radGridProducts.EditIndexes.Add(i); } //Added for Test purpose radGridProducts.Attributes.Add("onkeydown", "onKeyDown(this,event);"); int itemsCount = 0; int columnsCount = 0; StringBuilder builder = new StringBuilder(); // Attach the event handlers to the client side events of the TextBoxes. foreach (GridDataItem item in radGridProducts.MasterTableView.Items) { if (item is GridDataItem) { columnsCount = 0; for (int i = 2; i < radGridProducts.MasterTableView.RenderColumns.Length; i++) { GridColumn column = radGridProducts.MasterTableView.RenderColumns[i]; //if (item[column.UniqueName].Controls.Count != 0) //{ TextBox textBox = (item[column.UniqueName].Controls[0]) as TextBox; if (textBox != null) { textBox.Attributes.Add("ondblclick", "cellDoubleClickFunction('" + textBox.ClientID + "');"); textBox.Attributes.Add("onclick", "cellClick('" + textBox.ClientID + "');"); } if (i == 2 && !string.IsNullOrEmpty(textBox.Text)) { textBox.ReadOnly = true; textBox.Attributes.Add("class", "readOnly"); } //} columnsCount++; } itemsCount++; } } RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "init", "colls = " + columnsCount + ";rows=" + itemsCount + ";", true); }But still, it throws the same "Index out of bound" exception while getting the TextBox control.
Any solution for this Issue?
Thanks in Advance.