<telerik:RadGrid id="grdReporto" ShowStatusBar="true" DataSourceID="sqlReporto" runat="server" OnItemCommand="grdReporto_ItemCommand" OnItemCreated="grdReporto_ItemCreated" OnItemInserted="grdReporto_ItemInserted" OnItemDeleted="grdReporto_ItemDeleted" OnDataBound="grdReporto_DataBound" OnItemUpdated="grdReporto_ItemUpdated" AllowPaging="true" AllowFilteringByColumn="true" AllowSorting="true" AllowNaturalSort="false" AutoGenerateColumns="false" AllowMultiRowSelection="false"> <GroupingSettings CaseSensitive="false" /> <MasterTableView PageSize="15" NoDetailRecordsText="Sin Informacion" CommandItemDisplay="Top" NoMasterRecordsText="Sin Informacion" AutoGenerateColumns="false" DataSourceID="sqlReporto" DataKeyNames="rowno" AllowFilteringByColumn="true"> <CommandItemTemplate> <table style="width:100%"> <tr> <td width="50%" align="left"> <asp:LinkButton ID="InitInsertButton" Text="Nuevo Usuario" CommandName="InitInsert" runat="server"> <img src="../../img/21.png" alt="" /> Nuevo Usuario </asp:LinkButton> </td> <td width="50%" align="right"> <asp:LinkButton ID="LinkButton9" Text="Refresca" CommandName="Rebind" runat="server"> <img src="../../img/21.png" alt="" /> Refresca </asp:LinkButton> </td> </tr> </table> </CommandItemTemplate> <Columns> <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Reporto" ImageUrl="../../img/accept.png" UniqueName="Reporto" /> <telerik:GridBoundColumn UniqueName="rowno" ReadOnly="true" DataField="rowno" Visible="false"> </telerik:GridBoundColumn> <telerik:GridTemplateColumn HeaderText="Matricula" SortExpression="matricula" UniqueName="matricula" EditFormColumnIndex="0"> <ItemTemplate> <asp:Literal runat="server" ID="litMatricula" Text='<%# Eval("matricula") %>' /> </ItemTemplate> <EditItemTemplate> <span> <telerik:RadTextBox runat="server" ID="txtMatricula" Width="150px" Text='<%# Bind("matricula") %>' /> <span style="color: Red"> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txtMatricula" ErrorMessage="*" runat="server" /> </span> </span> </EditItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="Nombre" SortExpression="nombre" UniqueName="nombre" EditFormColumnIndex="0"> <ItemTemplate> <asp:Literal runat="server" ID="litNombre" Text='<%# Eval("nombre") %>' /> </ItemTemplate> <EditItemTemplate> <span> <telerik:RadTextBox runat="server" ID="txtNombre" Width="200px" Text='<%# Bind("nombre") %>' /> <span style="color: Red"> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="txtNombre" ErrorMessage="*" runat="server" /> </span> </span> </EditItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="Correo (sin @)" SortExpression="email" UniqueName="email" EditFormColumnIndex="1"> <ItemTemplate> <asp:Literal runat="server" ID="litEmail" Text='<%# Eval("email") %>' /> </ItemTemplate> <EditItemTemplate> <span> <telerik:RadTextBox runat="server" ID="txtEmail" Width="150px" Text='<%# Bind("email") %>' /> <span style="color: Red"> <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="txtEmail" ErrorMessage="*" runat="server" /> </span> </span> </EditItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="Ext" SortExpression="extension" UniqueName="extension" EditFormColumnIndex="1"> <ItemTemplate> <asp:Literal runat="server" ID="litExt" Text='<%# Eval("extension") %>' /> </ItemTemplate> <EditItemTemplate> <span> <telerik:RadTextBox runat="server" ID="txtExt" Width="100px" Text='<%# Bind("extension") %>' /> <span style="color: Red"> <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ControlToValidate="txtExt" ErrorMessage="*" runat="server" /> </span> </span> </EditItemTemplate> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="lastupdate" ReadOnly="true" HeaderText="Actualizacion" Visible="false" SortExpression="lastupdate" UniqueName="lastupdate"> </telerik:GridBoundColumn> <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" /> <telerik:GridButtonColumn ConfirmText="Eliminar este Usuario?" ConfirmDialogType="RadWindow" ConfirmTitle="Eliminar" ButtonType="ImageButton" CommandName="Delete" Text="Eliminar" UniqueName="DeleteColumn"> </telerik:GridButtonColumn> </Columns> <EditFormSettings ColumnNumber="2" CaptionDataField="nombre" CaptionFormatString="Editar Usuario {0}" InsertCaption="Nuevo Usuario"> <FormTableItemStyle Wrap="False"></FormTableItemStyle> <FormCaptionStyle CssClass="tb1"></FormCaptionStyle> <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White" Width="100%" /> <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" /> <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle> <EditColumn ButtonType="ImageButton" InsertText="Inserta" UpdateText="Actualiza" UniqueName="EditCommandColumn1" CancelText="Cancelar"> </EditColumn> <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle> </EditFormSettings> </MasterTableView> <ClientSettings EnableRowHoverStyle="true" /> <PagerStyle Mode="NumericPages"></PagerStyle></telerik:RadGrid>| <item name="PostalAddressState" displaySource="" dataSource="" label="State" control="DropDownList" direction="Horizontal" required="True" entityColumnName="Address.State" entityType="PostalAddress" width="80px"> |
| <field label="Select" value="0" selected="False" fieldType="String" goTo=""/> |
| <field label="ACT" value="ACT" selected="False" fieldType="String" goTo=""/> |
| <field label="NSW" value="NSW" selected="False" fieldType="String" goTo=""/> |
| <field label="NT" value="NT" selected="False" fieldType="String" goTo=""/> |
| <field label="QLD" value="QLD" selected="False" fieldType="String" goTo=""/> |
| <field label="SA" value="SA" selected="False" fieldType="String" goTo=""/> |
| <field label="TAS" value="TAS" selected="False" fieldType="String" goTo=""/> |
| <field label="VIC" value="VIC" selected="False" fieldType="String" goTo=""/> |
| <field label="WA" value="WA" selected="True" fieldType="String" goTo=""/> |
| </item> |
| <telerik:RadComboBox id="rcb{@id}" runat="server" Skin="WebBlue" AllowCustomText="false" MarkFirstMatch="true" |
| HighlightTemplatedItems="true" width="{@width}" EnableItemCaching="false"> |
| <items> |
| <xsl:for-each select="field"> |
| <xsl:choose> |
| <xsl:when test="@selected='True'"> |
| <telerik:RadComboBoxItem Value="{@value}" Selected="{@selected}" text="{@label}" /> |
| </xsl:when> |
| <xsl:otherwise> |
| <telerik:RadComboBoxItem Value="{@value}" text="{@label}" /> |
| </xsl:otherwise> |
| </xsl:choose> |
| </xsl:for-each> |
| </items> |
| </telerik:RadComboBox> |
| <telerik:RadComboBox id="rcbID24" runat="server" Skin="WebBlue" AllowCustomText="false" MarkFirstMatch="true" HighlightTemplatedItems="true" width="100px" EnableItemCaching="false"> |
| <items> |
| <telerik:RadComboBoxItem Value="0" text="Select" /> |
| <telerik:RadComboBoxItem Value="Br" text="Br" /> |
| <telerik:RadComboBoxItem Value="Captain" Selected="True" text="Captain" /> |
| <telerik:RadComboBoxItem Value="Dr" text="Dr" /> |
| <telerik:RadComboBoxItem Value="Father" text="Father" /> |
| <telerik:RadComboBoxItem Value="Miss" text="Miss" /> |
| <telerik:RadComboBoxItem Value="Mr" text="Mr" /> |
| <telerik:RadComboBoxItem Value="Mrs" text="Mrs" /> |
| <telerik:RadComboBoxItem Value="Ms" text="Ms" /> |
| <telerik:RadComboBoxItem Value="Professor" text="Professor" /> |
| <telerik:RadComboBoxItem Value="Rev" text="Rev" /> |
| <telerik:RadComboBoxItem Value="Sir" text="Sir" /> |
| <telerik:RadComboBoxItem Value="Sr" text="Sr" /> |
| <telerik:RadComboBoxItem Value="The Hon." text="The Hon." /> |
| </items> |
| </telerik:RadComboBox> |
| // transformedContent is the output from xslt. | |
| string transformedContent = obj.GetHtml(Context); | |
| Control ctrl = new Control(); | |
| ctrl = Page.ParseControl(transformedContent); | |
| // Debug statement to show that the combobox in question retains the correct selected value. | |
| foreach (Control ccc in ctrl.Controls) | |
| { | |
| if (ccc is RadComboBox && ccc.ID == "rcbID24") | |
| { | |
| string vvv = ((RadComboBox)ccc).SelectedValue; | |
| } | |
| } | |
| // Clear and dispose of any controls from any previously parsed node. | |
| pclXmlOutput.Controls.Clear(); | |
| pclXmlOutput.Dispose(); | |
| // Add the NEW control. | |
| pclXmlOutput.Controls.Add(ctrl); | |
| // Check to see if the comboBox has changed its value. | |
| foreach (Control ccc in ctrl.Controls) | |
| { | |
| if (ccc is RadComboBox && ccc.ID == "rcbID24") | |
| { | |
| string vvv = ((RadComboBox)ccc).SelectedValue; | |
| } | |
| } |
protected
void rgMembers_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem edititem = (GridEditableItem)e.Item;
/ /validate Percentage
GridTextBoxColumnEditor editorP = (GridTextBoxColumnEditor)edititem.EditManager.GetColumnEditor("Percentage");
TableCell cellP = (TableCell)editorP.TextBoxControl.Parent;
RangeValidator validatorP = new RangeValidator();
validatorP.ID =
"rgvPercentage";
validatorP.ControlToValidate = editorP.TextBoxControl.ID; //<-- Value is NULL
validatorP.Type =
ValidationDataType.Double;
validatorP.Display =
ValidatorDisplay.Dynamic;
validatorP.ErrorMessage =
"<br/>% must be between 0 and 100.";
validatorP.MinimumValue =
"0";
validatorP.MaximumValue =
"100";
cellP.Controls.Add(validatorP);
}
Why is the TextBoxControl.ID null ?
Seems to work with other type fields (i.e RadDatePicker.ID)
Thanks
protectedvoidpartnerGrid_ItemCreated(objectsender, GridItemEventArgs e){if(e.ItemisGridPagerItem){RadComboBox pageSize = (RadComboBox)e.Item.FindControl("PageSizeComboBox");RadComboBoxItem rcbItem100 = pageSize.FindItemByText("100");RadComboBoxItem rcbItem200 = pageSize.FindItemByText("200");if(rcbItem100 ==null){pageSize.Items.Add(newRadComboBoxItem("100"));pageSize.FindItemByText("100").Attributes.Add("ownerTableViewId", partnerGrid.MasterTableView.ClientID);}if(rcbItem200 ==null){pageSize.Items.Add(newRadComboBoxItem("200"));pageSize.FindItemByText("200").Attributes.Add("ownerTableViewId", partnerGrid.MasterTableView.ClientID);}pageSize.SelectedValue = partnerGrid.PageSize.ToString();}}
Inexplicably, ItemCreated is fired four times when the pagesize is changed. I suppose two are for each pager (even though
it's set to top-only, the bottom pager is still there), but I can't fathom the last two.
Worse, on the 3rd and 4th invocations of ItemCreated, the combobox has remembered the standard three (10, 20, 50) plus whatever
was selected, but has lost the unselected one. So, if the user goes directly to 200, when the grid re-renders
it shows 100 below 200 (as it was added but 200 was already there).
Secondly, on subsequent postbacks, the combobox will not accept a selectedValue of whatever the fifth item is now
and keeps defaulting to 10. The grid's page size is fine, so the query gets the appropriate number of items,
we just show 10 in the pulldown instead of the number they actually chose.
The ajax is really simple:<telerik:AjaxSettingAjaxControlID="partnerGrid"><UpdatedControls><telerik:AjaxUpdatedControlControlID="partnerGrid"LoadingPanelID="gridLoadingPanel"/></UpdatedControls></telerik:AjaxSetting>
Anytime we do something in the grid, show the loading panel while we're thinking about it. It seems as if
something's wrong in ajax land, but it can't be simpler than that.