<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource" Skin="Default"> <MasterTableView AutoGenerateColumns="true"> </MasterTableView> </telerik:RadGrid>Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Dim dt As DataTable If Session("dt") Is Nothing Then dt = New DataTable() dt.Columns.Add("money") For i As Integer = 1 To 10 dt.Rows.Add(i) Next Session("dt") = dt Else dt = TryCast(Session("dt"), DataTable) End If RadGrid1.DataSource = dt End SubOnItemDataBound="rgContacts_ItemDataBound"protected void rgContacts_ItemDataBound(object sender, GridItemEventArgs e){ if (e.Item is GridDataItem && e.Item.OwnerTableView.DataSourceID == "dsContacts") { Literal ltPrimaryContact = e.Item.FindControl("ltPrimaryContact") as Literal; }}e.Item.OwnerTableView.Items[e.Item.ItemIndex]'e.Item.OwnerTableView.Items[e.Item.ItemIndex]' threw an exception of type 'System.ArgumentOutOfRangeException' Telerik.Web.UI.GridDataItem {System.ArgumentOutOfRangeException}e.Item.OwnerTableView.Items[e.Item.ItemIndex]["con_Phone"].Text<telerik:RadGrid ID="rgTasks" runat="server" OnNeedDataSource="rgTasks_OnNeedDataSource" EnableViewState="false" AutoGenerateColumns="false" Skin="WebBlue" PageSize="10" EnableLinqExpressions="true" AllowPaging="true" AllowSorting="true" AllowFilteringByColumn="true" ShowStatusBar="true"> <PagerStyle AlwaysVisible="true" Position="Top" Width="100%" /> <MasterTableView DataKeyNames="OID" ClientDataKeyNames="OID" IsFilterItemExpanded="false"> <SortExpressions> <telerik:GridSortExpression FieldName="Startdatum" SortOrder="Ascending" /> </SortExpressions> <Columns> <telerik:GridBoundColumn DataField="OID" HeaderText="OID" Visible="false" AllowFiltering="false"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Volgnummer" HeaderText="Volgnummer" Visible="false" UniqueName="Volgnummer" AllowFiltering="true"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Taak" HeaderText="Dossier" DataType="System.String" UniqueName="Taak" AllowFiltering="false"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Status" HeaderText="Status" DataType="System.String" UniqueName="Status"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Startdatum" HeaderText="Startdatum" HeaderStyle-Width="110px" DataFormatString="<nobr>{0:dd/MM/yyyy}</nobr>" UniqueName="Startdatum" AllowFiltering="true"> </telerik:GridBoundColumn> </Columns> </MasterTableView> <ClientSettings EnableRowHoverStyle="true"> <ClientEvents OnRowClick="rowClick" /> <Resizing AllowColumnResize="true" /> <Selecting AllowRowSelect="true" /> <DataBinding EnableCaching="true"> </DataBinding> </ClientSettings></telerik:RadGrid><p> Filter toepassen:</p><br /><telerik:RadFilter ID="radFilter" runat="server" ExpressionPreviewPosition="Bottom" OnFieldEditorCreating="RadFilter1_FieldEditorCreating" OnApplyExpressions="RadFilter1_ApplyExpressions" Localization-FilterFunctionBetween="Tussen" Localization-FilterFunctionContains="Bevat" Localization-FilterFunctionDoesNotContain="Bevat Niet" Localization-FilterFunctionEndsWith="Eindigt op" Localization-FilterFunctionEqualTo="Gelijk aan" Localization-FilterFunctionGreaterThan="Groter dan" Localization-FilterFunctionGreaterThanOrEqualTo="Groter dan of gelijk aan" Localization-FilterFunctionIsEmpty="Is Leeg" Localization-FilterFunctionIsNull="Ongedefinieerd" Localization-FilterFunctionLessThan="Kleiner dan" Localization-FilterFunctionLessThanOrEqualTo="Kleiner dan of gelijk aan" Localization-FilterFunctionNotBetween="Niet tussen" Localization-FilterFunctionNotEqualTo="Niet gelijk aan" Localization-FilterFunctionNotIsEmpty="Is niet leeg" Localization-FilterFunctionNotIsNull="Is niet ongedefinieerd" Localization-FilterFunctionStartsWith="Begint met" Localization-GroupOperationAnd="En" Localization-GroupOperationNotAnd="En niet" Localization-GroupOperationNotOr="Of niet" Localization-GroupOperationOr="Of" AddExpressionToolTip="Expressie toevoegen" AddGroupToolTip="Groepering toeveoegen" ApplyButtonText="Toepassen" BetweenDelimeterText="en" Culture="nl-NL" RemoveToolTip="Verwijderen" ShowLineImages="true" SettingsFormatter="BinaryFormatter"> <FieldEditors> <custom:radfilterdropdowneditor datatextfield="Status" datavaluefield="Status" fieldname="Status" datatype="System.String" displayname="Status" /> </FieldEditors></telerik:RadFilter>protected void rgTasks_OnNeedDataSource(object sender, GridNeedDataSourceEventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("OID", typeof(long)); dt.Columns.Add("Taak", typeof(string)); dt.Columns.Add("Startdatum", typeof(DateTime)); dt.Columns.Add("Status", typeof(string)); dt.Columns.Add("Volgnummer", typeof(int)); StoredProcedure sp = new StoredProcedure("getAllAanvragen"); sp.addParameter("@regOID", "7"); DataSet ds = sp.executeDataSet(); if (ds != null && ds.Tables.Count > 0) { foreach (DataRow row in ds.Tables[0].Rows) { DataRow newRow = dt.NewRow(); newRow["OID"] = long.Parse(row["OID"].ToString()); newRow["Taak"] = CommonFunctions.makeDossiernummer(row["Dossiernummer"].ToString(), row["Volgnummer"].ToString()); newRow["Volgnummer"] = int.Parse(row["volgnummer"].ToString()); newRow["Startdatum"] = DateTime.Parse(row["gestartOp"].ToString()); newRow["Status"] = Hive.Util.HiveEnum.getDescription((CommonEnums.AanvraagStatus)row["status"]); dt.Rows.Add(newRow); } } rgTasks.DataSource = dt; } protected void RadFilter1_ApplyExpressions(object sender, RadFilterApplyExpressionsEventArgs e) { RadFilterSqlQueryProvider provider = new RadFilterSqlQueryProvider(); provider.ProcessGroup(e.ExpressionRoot); } protected void RadFilter1_FieldEditorCreating(object sender, RadFilterFieldEditorCreatingEventArgs e) { e.Editor = new RadFilterDropDownEditor(); }Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request. protected void RadGrid_Insert(object sender, GridCommandEventArgs e)
{
GridEditFormInsertItem InsertItem = e.Item as GridEditFormInsertItem;
try
{
string Name = (InsertItem.FindControl("txbName") as TextBox).Text;
string Address = (InsertItem.FindControl("txtAddress") as TextBox).Text;
string ContactPerson = (InsertItem.FindControl("txtContactPerson") as TextBox).Text;
int PhoneNumber = int.Parse((InsertItem.FindControl("txtPhoneNumber") as TextBox).Text);
string EmailID = (InsertItem.FindControl("txtEmail") as TextBox).Text;
RadAsyncUpload radAsyncUpload = InsertItem.FindControl("AsyncUpload1") as RadAsyncUpload;
UploadedFile file = radAsyncUpload.UploadedFiles[0];
string s = file.FileName;
string path = "images/";
byte[] fileData = new byte[file.InputStream.Length];
file.InputStream.Read(fileData, 0, (
int)file.InputStream.Length);
UploadedFile file1 = radAsyncUpload.UploadedFiles[0];
file1.SaveAs(Server.MapPath(path+s));
protected void rg_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == RadGrid.ExportToExcelCommandName) { rg.MasterTableView.GetColumn("x").Visible = false; rg.MasterTableView.GetColumn("y").Visible = true; } }