var templateColumn = new GridTemplateColumn(); templateColumn.UniqueName = role.RoleName; templateColumn.ItemTemplate = new RoleColumn(role); // add the dynamically created columns to the grid dgLoginRequest.MasterTableView.Columns.Add(templateColumn); public class RoleColumn : ITemplate { protected CheckBox roleCheckbox; private Role _role; public RoleColumn(Role role) { _role = role; } public void InstantiateIn(Control container) { roleCheckbox = new CheckBox { ID = "chkReader"}; roleCheckbox.AutoPostBack = false; roleCheckbox.DataBinding += new EventHandler(roleCheckbox_DataBinding); container.Controls.Add(roleCheckbox); } private void roleCheckbox_DataBinding(object sender, EventArgs e) { var cBox = (CheckBox)sender; var container = (GridDataItem)cBox.NamingContainer; cBox.Checked = (bool)DataBinder.Eval((container.DataItem), "Roles[" + _role.RoleID +"]"); } }foreach (GridDataItem item in dgLoginRequest.MasterTableView.Items) { var ads = item.DataItem; var cbx = (CheckBox) item.FindControl("chkReader"); }<telerik:RadButton ID="btnSaveProduct" runat="server" Skin="Web20" Text="Save"></telerik:RadButton>Private Sub btnSaveProduct_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveProduct.Click If pageIsValid() = True Then processPage() End IfEnd Sub<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false"> <MasterTableView> <Columns> <telerik:GridTemplateColumn UniqueName="ID" AllowFiltering="true" HeaderStyle-Width="100" SortExpression="ID" FilterControlWidth="50" HeaderText="ID"> <HeaderTemplate> <asp:CheckBox ID="IDCheck" runat="server" CssClass="HeaderCheckBox" Text="ID" /> </HeaderTemplate> <ItemTemplate> <asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>'></asp:Label> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn UniqueName="Name" AllowFiltering="true" HeaderStyle-Width="100" SortExpression="ID" FilterControlWidth="50" HeaderText="Name"> <HeaderTemplate> <asp:CheckBox ID="NameCheck" runat="server" CssClass="HeaderCheckBox" Text="Name" /> </HeaderTemplate> <ItemTemplate> <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>'></asp:Label> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn UniqueName="RandomText" AllowFiltering="true" HeaderStyle-Width="100" SortExpression="RandomText" FilterControlWidth="50" HeaderText="RandomText"> <HeaderTemplate> <asp:CheckBox ID="RandomTextCheck" runat="server" CssClass="HeaderCheckBox" Text="Random" /> </HeaderTemplate> <ItemTemplate> <asp:Label ID="RandomTextLabel" runat="server" Text='<%# Eval("RandomText") %>'></asp:Label> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </MasterTableView> </telerik:RadGrid> <asp:Button ID="PDFExportButton" runat="server" OnClick="ExportToPDF" Text="Export to PDF" /> <asp:Button ID="ExcelExportButton" runat="server" OnClick="ExportToExcel" Text="Export to Excel" />public partial class Default : System.Web.UI.Page { protected override void OnInit(EventArgs e) { RadGrid1.DataSource = GetDataSource(); RadGrid1.DataBind(); base.OnInit(e); } protected void Page_Load(object sender, EventArgs e) { } protected List<Person> GetDataSource() { List<Person> peeps = new List<Person>(); for (int i = 0; i < 10; i++) { Person p = new Person { Name = "Test" + i.ToString(), ID = i, RandomText = DateTime.Now.Millisecond.ToString() }; peeps.Add(p); } return peeps; } protected void ExportToPDF(object sender, EventArgs e) { RadGrid1.ExportSettings.ExportOnlyData = true; RadGrid1.ExportSettings.HideStructureColumns = true; RadGrid1.ExportSettings.IgnorePaging = true; //RadGrid1.ExportSettings.OpenInNewWindow = true; RadGrid1.MasterTableView.ExportToPdf(); } protected void ExportToExcel(object sender, EventArgs e) { RadGrid1.ExportSettings.ExportOnlyData = true; RadGrid1.ExportSettings.HideStructureColumns = true; RadGrid1.ExportSettings.IgnorePaging = true; //RadGrid1.ExportSettings.OpenInNewWindow = true; RadGrid1.MasterTableView.ExportToExcel(); }}
protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)
{
if (isEdit) { RadTabStrip1.FindTabByText(LatestMenuItem).Selected = true; RadAjaxManager manager = RadAjaxManager.GetCurrent(this.Page); manager.ResponseScripts.Add("if(confirm('Are you sure?'))" + manager.ClientID + ".ajaxRequest('tab')"); } else { LatestMenuItem = e.Tab.Text; string ctrl = e.Tab.Attributes["ctrl"] + ".ascx"; LoadUserControl(ctrl,false); e.Tab.Selected = true; }
}protected void ManagerAjaxRequest(object sender, AjaxRequestEventArgs e)
{
LoadUserControl(NewControlName, true);
}<telerik:RadAjaxManagerProxy ID="RadAjaxManager1" runat="server" > <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadTabStrip1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadTabStrip1" /> <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadTabStrip1" /> <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManagerProxy>
| protected void FillFieldList(MappingType mtType, Guid? nguidFieldMappingID) |
| { |
| DataTable dtLayout = Property.GetDBSchema(); |
| RadTextBox rtxtNewTextBox; |
| FieldMappingItem fmiMappings = new FieldMappingItem(); |
| StringBuilder sbControl; |
| string strMappedName = ""; |
| bool bolMappedFound = false; |
| if ((mtType == MappingType.ReloadMapping) || (mtType == MappingType.LoadSavedMapping)) |
| { |
| fmiMappings = new FieldMappingItem(nguidFieldMappingID); |
| } |
| foreach (DataRow drData in dtLayout.Rows) |
| { |
| if ((drData["DataTypeName"].ToString() != "uniqueidentifier") && (drData["ColumnName"].ToString() != "Created")) |
| { |
| strMappedName = string.Empty; |
| sbControl = new StringBuilder(); |
| sbControl.Append("<div id=\"div"); |
| sbControl.Append(drData["ColumnName"].ToString()); |
| sbControl.Append("\" onclick=\"SelectRow('div"); |
| sbControl.Append(drData["ColumnName"].ToString()); |
| sbControl.Append("');\""); |
| foreach (FieldMappingDetailItem fmdiDetails in fmiMappings.Details) |
| { |
| if (fmdiDetails.FieldName == drData["ColumnName"].ToString()) |
| { |
| bolMappedFound = true; |
| sbControl.Append(" class=\"MapFieldMapped\">"); |
| strMappedName = fmdiDetails.MappedName; |
| break; |
| } |
| } |
| if (bolMappedFound) |
| { |
| bolMappedFound = false; |
| } |
| else |
| { |
| sbControl.Append(">"); |
| } |
| this.pnlFields.Controls.Add(new LiteralControl(sbControl.ToString())); |
| rtxtNewTextBox = new RadTextBox(); |
| rtxtNewTextBox.ID = "rtxt" + drData["ColumnName"].ToString(); |
| rtxtNewTextBox.CssClass = "FormFieldMapping"; |
| rtxtNewTextBox.Label = drData["ColumnName"].ToString(); |
| rtxtNewTextBox.LabelCssClass = "FormLabel"; |
| rtxtNewTextBox.EmptyMessage = strMappedName; |
| rtxtNewTextBox.Text = strMappedName; |
| this.pnlFields.Controls.Add(rtxtNewTextBox); |
| sbControl = new StringBuilder(); |
| sbControl.Append("<input type=\"hidden\" id=\"hdn"); |
| sbControl.Append(drData["ColumnName"].ToString()); |
| sbControl.Append("\" value=\""); |
| sbControl.Append(rtxtNewTextBox.ClientID); |
| sbControl.Append("\" />"); |
| this.pnlFields.Controls.Add(new LiteralControl(sbControl.ToString())); |
| this.pnlFields.Controls.Add(new LiteralControl("</div>")); |
| } |
| } |
| } |
<telerik:RadGrid AutoGenerateColumns="False" ID="RadGridFHData"
AllowFilteringByColumn="True" AllowPaging="True"
AllowSorting="True" runat="server" ShowGroupPanel="true"
onitemcommand="RadGridFHData_ItemCommand">
<PagerStyle Mode="NextPrevAndNumeric" />
<GroupingSettings CaseSensitive="false" />
<MasterTableView TableLayout="Fixed" DataKeyNames="FHID" ClientDataKeyNames="FHID">
<Columns>
<telerik:GridBoundColumn HeaderText="FHID" DataField="FHID" UniqueName="FHID"
SortExpression="FHID" HeaderStyle-Width="100px" FilterControlWidth="100px"
AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" />
<telerik:GridBoundColumn HeaderText="病人ID" DataField="PID" UniqueName="PID"
SortExpression="PID" HeaderStyle-Width="100px" FilterControlWidth="100px"
AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" />
<telerik:GridBoundColumn HeaderText="病人姓名" DataField="PName" UniqueName="PName"
SortExpression="PName" HeaderStyle-Width="100px" FilterControlWidth="100px"
AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" />
<telerik:GridNumericColumn HeaderText="测量值" DataField="FHValue" UniqueName="FHValue"
SortExpression="FHValue" HeaderStyle-Width="100px" FilterControlWidth="140px"
AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" />
<telerik:GridDateTimeColumn HeaderText="测量日期" DataField="ReceiveDate" UniqueName="ReceiveDate"
SortExpression="ReceiveDate" HeaderStyle-Width="100px" FilterControlWidth="140px"
AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" />
<telerik:GridBoundColumn HeaderText="查看状态" DataField="isNew" UniqueName="isNew"
SortExpression="isNew" HeaderStyle-Width="100px" FilterControlWidth="140px"
AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" />
<telerik:GridBoundColumn HeaderText="医生留言" DataField="Remark" UniqueName="Remark"
SortExpression="Remark" HeaderStyle-Width="100px" FilterControlWidth="140px"
AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" />
</Columns>
<NestedViewSettings>
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="FHID" MasterKeyField="FHID" />
</ParentTableRelation>
</NestedViewSettings>
<NestedViewTemplate >
<table>
<tr>
<td align="left" colspan="3">
<telerik:RadChart ID="RadChartFH" runat="Server"
Width="495px" AutoLayout="true" Skin="Mac">
<ClientSettings EnableZoom="false" ScrollMode="XOnly" XScale="4" />
<Series>
<telerik:ChartSeries Name="ChartFH" DataYColumn="FHValue" Type="Line">
<Appearance FillStyle-MainColor="223, 87, 60">
</Appearance>
</telerik:ChartSeries>
</Series>
<Legend Visible="false"></Legend>
<ChartTitle TextBlock-Text="Scrolling only (initial XScale applied)">
</ChartTitle>
</telerik:RadChart>
</td>
</tr>
</table>
</NestedViewTemplate>
</MasterTableView>
<ClientSettings AllowDragToGroup="true" >
<Selecting AllowRowSelect="true" />
<Scrolling AllowScroll="true" UseStaticHeaders="true" />
</ClientSettings>
</telerik:RadGrid>
<asp:SqlDataSource ID="SqlDataSource1" CancelSelectOnNullParameter="false" runat="server" ConnectionString="<%$ appSettings:XCareSqlConn%>"
ProviderName="System.Data.SqlClient" SelectCommandType="StoredProcedure" SelectCommand="ChartFHData">
<SelectParameters>
<asp:Parameter Name="FHID" Type="String"/>
</SelectParameters>
</asp:SqlDataSource>
<asp:Panel ID="pnlSearch" runat="server" DefaultButton="ibtnSearch"> <table cellpadding="0" cellspacing="0" class="search_restaurant_table"> <tr> <td class="search_restaurant_table_right"> </td> <td class="search_restaurant_table_spacer"> </td> <td> <asp:HiddenField ID="hidResId" runat="server" /> <asp:HiddenField ID="hidMessage" runat="server" Value="Search Restaurant (Name/Type/Category/Cuisine)." /> </td> </tr> <tr> <td class="search_restaurant_table_right"> <asp:Label ID="lblTitle" runat="server" SkinID="label_9_bold" Text="Restaurant :" Width="170"></asp:Label> </td> <td class="search_restaurant_table_spacer"> </td> <td> <table cellpadding="0" cellspacing="0" class="search_restaurant_table"> <tr> <td class="search_restaurant_table_inner"> <asp:TextBox ID="txtRestaurantSearch" runat="server" Width="400px" AutoComplete="Off" ></asp:TextBox> <cc1:PopupControlExtender ID="txtRestaurantSearch_PopupControlExtender" runat="server" TargetControlID="txtRestaurantSearch" PopupControlID="pnlRestaurant" Position="Bottom" OffsetY="0"> </cc1:PopupControlExtender> <telerik:RadWindowManager ID="rwmResInfo" runat="server" Style="width: 750px; height: 350px" OnClientShow="radResInfo_show" OnClientClose="radResInfo_close" Behavior="Default" InitialBehavior="Default" EnableViewState="false" Modal="true" VisibleStatusbar="false"> <Windows> <telerik:RadWindow ID="rwdResInfo" runat="server" Skin="Office2007"> </telerik:RadWindow> </Windows> </telerik:RadWindowManager> </td> <td> <asp:ImageButton ID="ibtnSearch" runat="server" CausesValidation="False" ImageUrl="~/Images/page/search.png" ToolTip="Search" /> <div style="position: fixed; left: 110%;"> <asp:Button ID="btnPostBack" runat="server" CausesValidation="false" Visible="true" Width="1" Height="1"/> </div> </td> </tr> </table> </td> </tr> <tr> <td class="search_restaurant_table_right"> </td> <td class="search_restaurant_table_spacer"> </td> <td align="left"> <asp:Label ID="lblMessage" runat="server" SkinID="label_8" Text="Search Restaurant (Name/Type/Category/Cuisine)."></asp:Label> <asp:RequiredFieldValidator ID="rfvRestaurant" runat="server" ControlToValidate="txtRestaurantSearch" Display="Dynamic" ErrorMessage="* Select Restaurant" Enabled="False"></asp:RequiredFieldValidator> <div style="position: absolute; left: 110%;"> <asp:Panel ID="pnlRestaurant" runat="server" BackColor="#E6F2E7" Width="670px" BorderWidth="1" BorderStyle="NotSet" BorderColor="#999999"> <div style="width:100%; margin:0px auto; overflow-y:scroll;"> <table cellpadding="0" cellspacing="0" style="padding:5px; width:95%;"> <tr> <td style="background-color:#D1DEBE;" align="Left"> <table cellpadding="0" cellspacing="0" class="search_restaurant_table"> <tr> <td class="search_restaurant_table_search_more"> <asp:LinkButton ID="lbtnSearch" runat="server" CausesValidation="False" SkinID="linkbutton_8" Text="Search more"> </asp:LinkButton> <asp:Label ID="Label2" runat="server" SkinID="label_8" Text="with filters."> </asp:Label> </td> <td> <table cellpadding="0" cellspacing="0" class="search_restaurant_table"> <tr> <td class="search_restaurant_table_sort"> <asp:Label ID="Label3" runat="server" SkinID="label_8" Text="Sortings :"></asp:Label> </td> <td class="search_restaurant_table_right"> </td> <td class="search_restaurant_table_sort_parameter"> <asp:DropDownList ID="cmbSort1" runat="server" SkinID="dropdownlist_8" Width="80px"> <asp:ListItem Text="(None)" Value=""></asp:ListItem> <asp:ListItem Text="Name" Value="Name"></asp:ListItem> <asp:ListItem Text="Category" Value="Category"></asp:ListItem> <asp:ListItem Text="Cuisine" Value="Cuisine"></asp:ListItem> <asp:ListItem Text="Type" Value="Type"></asp:ListItem> </asp:DropDownList> </td> <td class="search_restaurant_table_sort_value"> <asp:DropDownList ID="cmbSort1Value" runat="server" SkinID="dropdownlist_8" Width="50px"> <asp:ListItem Text="Asc" Value="Asc"></asp:ListItem> <asp:ListItem Text="Desc" Value="Desc"></asp:ListItem> </asp:DropDownList> </td> <td class="search_restaurant_table_sort_parameter"> <asp:DropDownList ID="cmbSort2" runat="server" SkinID="dropdownlist_8" Width="80px"> <asp:ListItem Text="(None)" Value=""></asp:ListItem> <asp:ListItem Text="Name" Value="Name"></asp:ListItem> <asp:ListItem Text="Category" Value="Category"></asp:ListItem> <asp:ListItem Text="Cuisine" Value="Cuisine"></asp:ListItem> <asp:ListItem Text="Type" Value="Type"></asp:ListItem> </asp:DropDownList> </td> <td class="search_restaurant_table_sort_value"> <asp:DropDownList ID="cmbSort2Value" runat="server" SkinID="dropdownlist_8" Width="50px"> <asp:ListItem Text="Asc" Value="Asc"></asp:ListItem> <asp:ListItem Text="Desc" Value="Desc"></asp:ListItem> </asp:DropDownList> </td> <td class="search_restaurant_table_sort_parameter"> <asp:DropDownList ID="cmbSort3" runat="server" SkinID="dropdownlist_8" Width="80px"> <asp:ListItem Text="(None)" Value=""></asp:ListItem> <asp:ListItem Text="Name" Value="Name"></asp:ListItem> <asp:ListItem Text="Category" Value="Category"></asp:ListItem> <asp:ListItem Text="Cuisine" Value="Cuisine"></asp:ListItem> <asp:ListItem Text="Type" Value="Type"></asp:ListItem> </asp:DropDownList> </td> <td class="search_restaurant_table_sort_value"> <asp:DropDownList ID="cmbSort3Value" runat="server" SkinID="dropdownlist_8" Width="50px"> <asp:ListItem Text="Asc" Value="Asc"></asp:ListItem> <asp:ListItem Text="Desc" Value="Desc"></asp:ListItem> </asp:DropDownList> </td> <td style="text-align: left"> <asp:LinkButton ID="btnOK" runat="server" CausesValidation="False" SkinID="linkbutton_8" Text="OK"></asp:LinkButton> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td> <telerik:RadGrid ID="grdResult" runat="server" EnableEmbeddedSkins="False" EnableViewState="false" AllowMultiRowSelection="True" Skin="custom_econcierge" EnableTheming="False" AllowPaging="True" AllowSorting="true" GridLines="Horizontal" PageSize="2" Width="640px"> <PagerStyle AlwaysVisible="True" /> <ClientSettings EnablePostBackOnRowClick="True"> <Selecting AllowRowSelect="True" /> </ClientSettings> <mastertableview> <rowindicatorcolumn> <HeaderStyle Width="20px" /> </rowindicatorcolumn> <expandcollapsecolumn> <HeaderStyle Width="20px" /> </expandcollapsecolumn> <Columns> <telerik:GridButtonColumn CommandName="View" Text="View" UniqueName="View" ItemStyle-Width="30px" HeaderStyle-Width="30px" FooterStyle-Width="30px"> <ItemStyle BackColor="Lavender" ForeColor="Blue" /> </telerik:GridButtonColumn> </Columns> </mastertableview> </telerik:RadGrid> </td> </tr> </table> </div> </asp:Panel> </div> </td> </tr> </table></asp:Panel>
Thank you.