I have a RadGrid in a user control on a webpage
1. The radgrid has one template GridHyperLinkColumn and many other columns loaded from the datatable.
2. The grid loads successfully from a Datatable with the template column.
3. I have a Checkbox column and it shows well.
4. Button click calls MarkSelectedInvalid()
** It never gets inside the For Loop as the RadGrid1.MasterTableView.Items is zero. I have enabledviewstate on page, and in HTML Mark up for RadGrid.
<telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="false" AllowMultiRowEdit = "true" SortingSettings-SortedBackColor="#999999" OnPreRender="RadGrid1_PreRender" CellSpacing="-1" GridLines="Both" Font-Size="xx-Small" EnableViewState="true" ViewStateMode="Enabled"> <GroupingSettings CollapseAllTooltip="Collapse all groups" /> <SortingSettings SortedBackColor="153, 153, 153" /> <MasterTableView EditMode="InPlace" EnableColumnsViewState="true" EnableViewState="true"> <RowIndicatorColumn Visible="False"> </RowIndicatorColumn> <ExpandCollapseColumn Created="True"> </ExpandCollapseColumn> <Columns> <telerik:GridHyperLinkColumn DataNavigateUrlFields="Path" DataTextField="Path" FilterControlAltText="Filter Path column" HeaderText="Path" SortExpression="Path" Target="_blank" UniqueName="Path1"> </telerik:GridHyperLinkColumn> </Columns> </MasterTableView> </telerik:RadGrid>
Code:
private void MarkSelectedItemsInvalid() { foreach (GridDataItem item in this.RadGrid1.MasterTableView.Items) { TableCell cell = item["MarkInvalid"]; CheckBox checkBox = (CheckBox)cell.Controls[0]; if (checkBox.Checked) { string path = (item["Path"].FindControl("TB_Path") as TextBox).Text; string title = (item["Title"].FindControl("TB_Title") as TextBox).Text; item.Enabled = false; var dictionary = new Dictionary<string, string>(); dictionary.Add("ContentTypeId", GetContentTypeID(qsURLSite, GetLibraryFromURL(path), "Invalid")); UpdateMetaData(path,GetLibraryFromURL(path), dictionary); } } }