<div id="ctl00_ctl00_ctl00_ctl00_contentHolder_contentHolder_pnlMainNavPanel" style="display: block;" class="RadForm RadForm_Vista rfdButton"><div style="height: 100%; width: 100%; visibility: visible; overflow: hidden;" class="RadPanelBar RadPanelBar_Vista" id="ctl00_ctl00_contentHolder_contentHolder_pnlMainNav"> <!-- 2010.2.713.35 --><telerik:AjaxSetting AjaxControlID="btnDoStuff"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="pnlMainNav" LoadingPanelID="pnlLoading" UpdatePanelHeight="100%" /> </UpdatedControls> </telerik:AjaxSetting>
Hello, I have a grid that is created in runtime. The header of my grid is empty after a postback.
private void BindGrid(RadGrid _radgrid ,string[] campos)
{
List<string> parametrosCamposRetornados = new BRPesquisa().RecuperaCamposRetornados(Pesquisa.IdConsulta, Pesquisa.NumeroPesquisa);
foreach (string x in campos)
{
if (x != "")
{
if (parametrosCamposRetornados.Contains(x.ToUpper()) || parametrosCamposCDRRetornados.Count ==0)
{
GridBoundColumn gridBoundColumn = new GridBoundColumn();
gridBoundColumn.UniqueName = x;
gridBoundColumn.DataField = x;
gridBoundColumn.HeaderText = x;
_radgrid.Columns.Add(gridBoundColumn);
}
}
}
}
rdgResultado.DataSource = dtResultado;
rdgResultado.DataBind();
Hi,
I'm using AsyncUpload in a RadGrid
<
FormTemplate>.
When the User makes the changes to the record I want to Change the filename when it uploads it. The below works for the first row in the radgrid. When I try to update the second row I get object reference not set to an instance of an object.
Am i missing something?
Thanks
string filenamenew = string.Empty; GridEditFormItem editedItem = (GridEditFormItem)(gvContractors.MasterTableView.GetItems(GridItemType.EditFormItem)[0]); RadTextBox txtcustomername = (RadTextBox)editedItem.FindControl("txtcustomername"); filenamenew = txtcustomername.Text.Replace(" ", "_"); e.File.SaveAs(System.Configuration.ConfigurationManager.AppSettings["ContractorDatabaseUploads"] + filenamenew + "_Certificate" + e.File.GetExtension());>
<telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1" LoadingPanelID="progressLoader"> <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="Vertical" AllowSorting="true" AllowPaging="true" AllowCustomPaging="false" AutoGenerateColumns="false" EnableHeaderContextMenu="true" Skin="Default" PageSize="15" OnNeedDataSource="RadGrid1_NeedDataSource" > <ExportSettings> <Pdf FontType="Subset" PaperSize="A4" /> <Excel Format="Html" /> <Csv ColumnDelimiter="Comma" RowDelimiter="NewLine" /> </ExportSettings> <MasterTableView CommandItemDisplay="Top" PagerStyle-AlwaysVisible="False" > <PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle> <CommandItemTemplate> <asp:LinkButton ID="btn_save" runat="server" CommandName="saveGrid" ><asp:Image runat="server" ID="img_save" ImageUrl="~/_resources/images/icons/tick.png"/></asp:LinkButton> <asp:LinkButton ID="btn_excel" runat="server" CommandName="excel" ><asp:Image runat="server" ID="Image1" ImageUrl="~/_resources/images/icons/xls_grey.gif"/></asp:LinkButton> </CommandItemTemplate> </MasterTableView> <ClientSettings ReorderColumnsOnClient="True" AllowDragToGroup="True" AllowColumnsReorder="True" EnablePostBackOnRowClick="False" AllowGroupExpandCollapse="True" > <Selecting AllowRowSelect="true" /> <Resizing AllowRowResize="True" AllowColumnResize="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="False"> </Resizing> </ClientSettings> </telerik:RadGrid></telerik:RadAjaxPanel>Public Property Datasource() As DataTable Get Return _Datasource End Get Set(ByVal value As DataTable) _Datasource = value End Set End Property Public Property GridDataKeyNames() As String Get Return _GridDataKeyNames End Get Set(ByVal value As String) _GridDataKeyNames = value End Set End Property Public Property GridContextMenu() As Boolean Get Return _GridContextMenu End Get Set(ByVal value As Boolean) _GridContextMenu = value End Set End Property Public Property GridRowClick() As Boolean Get Return _GridRowClick End Get Set(ByVal value As Boolean) _GridRowClick = value End Set End Property Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then ViewState("gridData") = sectionCache ViewState("GridDataKeyNames") = GridDataKeyNames ViewState("GridContextMenu") = GridContextMenu ViewState("GridRowClick") = GridRowClick Else sectionCache = ViewState("gridData") GridDataKeyNames = ViewState("GridDataKeyNames") GridContextMenu = ViewState("GridContextMenu") GridRowClick = ViewState("GridRowClick") End If If Not Cache(sectionCache) Is Nothing Then Datasource = Cache(sectionCache) Else Cache(sectionCache) = Datasource End If standardGrid() If Not IsPostBack Then Dim hdn_field As HiddenField = TryCast(Page.Master.FindControl("hdn_pageId"), HiddenField) dataGrid = New DataRadGrid dataGrid.pageId = New Guid(hdn_field.Value.ToString()) dataGrid.coreEntityId = Session.Item("RealId") Dim gridSettings As String = dataGrid.LoadSettings() If gridSettings <> "" Then Dim LoadPersister As New GridSettingsPersister(RadGrid1) LoadPersister.LoadSettings(gridSettings) End If End If End Sub Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource RadGrid1.MasterTableView.VirtualItemCount = Datasource.Rows.Count RadGrid1.DataSource = Datasource End SubProtected Sub standardGrid() If GridRowClick Then If GridDataKeyNames = "" Then GridDataKeyNames = "ROWCLICK" Else GridDataKeyNames += ",ROWCLICK" End If RadGrid1.ClientSettings.ClientEvents.OnRowClick = "RowClick" End If If GridDataKeyNames <> "" Then Dim dataKeyNamesArray() As String = GridDataKeyNames.Split(",".ToArray()) RadGrid1.MasterTableView.ClientDataKeyNames = dataKeyNamesArray RadGrid1.MasterTableView.DataKeyNames = dataKeyNamesArray End If If GridContextMenu Then RadGrid1.ClientSettings.ClientEvents.OnRowContextMenu = "RowContextMenu" End If Dim boundColumn As GridBoundColumn RadGrid1.MasterTableView.Columns.Clear() For Each column As DataColumn In Datasource.Columns If GridDataKeyNames <> "" Then If Not GridDataKeyNames.Contains(column.ColumnName.ToString()) Then If column.ColumnName.ToString().IndexOf("_HIDDEN") < 0 Then boundColumn = New GridBoundColumn RadGrid1.MasterTableView.Columns.Add(boundColumn) boundColumn.DataField = column.ColumnName boundColumn.HeaderText = column.ColumnName.Replace("_", " ") boundColumn.DataFormatString = "<nobr>{0}</nobr>" Else boundColumn = New GridBoundColumn RadGrid1.MasterTableView.Columns.Add(boundColumn) boundColumn.DataField = column.ColumnName boundColumn.HeaderText = column.ColumnName boundColumn.Visible = False End If End If Else If column.ColumnName.ToString().IndexOf("_HIDDEN") < 0 Then boundColumn = New GridBoundColumn RadGrid1.MasterTableView.Columns.Add(boundColumn) boundColumn.DataField = column.ColumnName boundColumn.HeaderText = column.ColumnName.Replace("_", " ") boundColumn.DataFormatString = "<nobr>{0}</nobr>" Else boundColumn = New GridBoundColumn RadGrid1.MasterTableView.Columns.Add(boundColumn) boundColumn.DataField = column.ColumnName boundColumn.HeaderText = column.ColumnName boundColumn.Visible = False End If End If Next End Sub