protected void Page_Init(object sender, System.EventArgs e) { DefineGridStructure(); // this method will populate this RadGrid1. } private void DefineGridStructure() { // populate this RadGrid1. string sqlCxn = "Data Source=DESQL2008;Initial Catalog=DrawOnTime;User Id=ontimeweb;Password=ontime1234;", sql2008; sql2008 = "select IncidentId, IncidentNumber, Incidents.Name, " + " CASE " + " WHEN DATEPART (YYYY,ReportedDate)=1899 THEN ' / / '" + " ELSE" + " CONVERT (char(8),ReportedDate,1)" + " END " + " as 'Reported Date'," + " Substring(Incidents.Description,1,72)+'\n'+" + " Substring(Incidents.Description,73,72)+'\n'+" + " Substring(Incidents.Description,145,72)+'\n'+" + " Substring(Incidents.Description,217,72) as IncidentDesc," + "Users.FirstName + ' '+" + "Users.LastName as 'IT Employee Assigned', WorkFlowSteps.StepName as 'Flow'," + "000.00 as nLabor, space(40) as workDescr" + " from incidents " + "left join WorkFlowSteps on Incidents.WorkFlowStepId = WorkFlowSteps.WorkFlowStepId " + "left join WorkLog on IncidentId = ItemId " + " left join Users on Users.UserId=Incidents.AssignedToId " + " where (WorkLogId is null and Left(WorkFlowSteps.StepName,6) <>'Closed' and Left(WorkFlowSteps.StepName,3) <>'UAT' and " + "Left(WorkFlowSteps.StepName,4)<>'Hold' ) and " + " ( AssignedToId=0 or AssignedToId = @UID ) "; SqlConnection dbconn = new SqlConnection(sqlCxn), dbconn2; dbconn2 = new SqlConnection(sqlCxn); dbconn.Open(); dbconn2.Open(); SqlCommand myCommand = new SqlCommand(sql2008, dbconn), mycommand2; mycommand2 = new SqlCommand(sql2008, dbconn2); SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand), myAdapter2; myAdapter2 = new SqlDataAdapter(mycommand2); DataSet ds = new DataSet(), ds2; ds2 = new DataSet(); myCommand.Parameters.AddWithValue("UID", 5); //Default.UID); myAdapter.Fill(ds);// if (ds.Tables[0].Rows.Count == 0) // this.btnSubmit.Visible = false; // .Enabled = false; mycommand2.Parameters.AddWithValue("UID", 5); myAdapter2.Fill(ds2); RadGrid1.DataSource = ds; RadGrid1.DataBind();/* RadGrid2.DataSource = ds2; RadGrid2.DataBind(); */ RadGrid2.Visible = false;// RadGrid1.Visible = true; }}<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title> <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" /></head><body> <form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> <Scripts> <%--Needed for JavaScript IntelliSense in VS2010--%> <%--For VS2008 replace RadScriptManager with ScriptManager--%> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" /> </Scripts> </telerik:RadScriptManager> <script type="text/javascript"> //Put your JavaScript code here. </script> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> </telerik:RadAjaxManager> <div> </div> <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" Width = "817px" Height="341px" MasterTableView-CanRetrieveAllData ="true" MasterTableView-Visible ="true" AllowAutomaticUpdates="True" ><MasterTableView><RowIndicatorColumn><HeaderStyle Width="20px"></HeaderStyle></RowIndicatorColumn><ExpandCollapseColumn><HeaderStyle Width="20px"></HeaderStyle></ExpandCollapseColumn> <Columns> <telerik:GridBoundColumn DataField="IncidentNumber" HeaderText="Incident #" ReadOnly="True" UniqueName="column"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Name" HeaderText="Subject" UniqueName="column1"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ActualDuration" DataType="System.Decimal" DefaultInsertValue="0.00" HeaderText="Actual Duration" Resizable="False" UniqueName="column2"> </telerik:GridBoundColumn> </Columns></MasterTableView> </telerik:RadGrid> <telerik:RadGrid ID="RadGrid2" runat="server" GridLines="None" style="margin-top: 27px"><MasterTableView AutoGenerateColumns="False" DataKeyNames="IncidentId"><RowIndicatorColumn><HeaderStyle Width="20px"></HeaderStyle></RowIndicatorColumn><ExpandCollapseColumn><HeaderStyle Width="20px"></HeaderStyle></ExpandCollapseColumn> <Columns> <telerik:GridBoundColumn DataField="IncidentId" DataType="System.Int32" HeaderText="IncidentId" ReadOnly="True" SortExpression="IncidentId" UniqueName="IncidentId"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="IncidentNumber" HeaderText="IncidentNumber" SortExpression="IncidentNumber" UniqueName="IncidentNumber"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name" UniqueName="Name"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description" UniqueName="Description"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ReplicationProcedures" HeaderText="ReplicationProcedures" SortExpression="ReplicationProcedures" UniqueName="ReplicationProcedures"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Resolution" HeaderText="Resolution" SortExpression="Resolution" UniqueName="Resolution"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Notes" HeaderText="Notes" SortExpression="Notes" UniqueName="Notes"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="PriorityTypeId" DataType="System.Int32" HeaderText="PriorityTypeId" SortExpression="PriorityTypeId" UniqueName="PriorityTypeId"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="StatusTypeId" DataType="System.Int32" HeaderText="StatusTypeId" SortExpression="StatusTypeId" UniqueName="StatusTypeId"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="SeverityTypeId" DataType="System.Int32" HeaderText="SeverityTypeId" SortExpression="SeverityTypeId" UniqueName="SeverityTypeId"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ProjectId" DataType="System.Int32" HeaderText="ProjectId" SortExpression="ProjectId" UniqueName="ProjectId"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ReportedById" DataType="System.Int32" HeaderText="ReportedById" SortExpression="ReportedById" UniqueName="ReportedById"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="AssignedToId" DataType="System.Int32" HeaderText="AssignedToId" SortExpression="AssignedToId" UniqueName="AssignedToId"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="WorkflowStepId" DataType="System.Int32" HeaderText="WorkflowStepId" SortExpression="WorkflowStepId" UniqueName="WorkflowStepId"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ReportedByCustomerContactId" DataType="System.Int32" HeaderText="ReportedByCustomerContactId" SortExpression="ReportedByCustomerContactId" UniqueName="ReportedByCustomerContactId"> </telerik:GridBoundColumn> <telerik:GridCheckBoxColumn DataField="PubliclyViewable" DataType="System.Boolean" HeaderText="PubliclyViewable" SortExpression="PubliclyViewable" UniqueName="PubliclyViewable"> </telerik:GridCheckBoxColumn> <telerik:GridBoundColumn DataField="ReportedDate" DataType="System.DateTime" HeaderText="ReportedDate" SortExpression="ReportedDate" UniqueName="ReportedDate"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="StartDate" DataType="System.DateTime" HeaderText="StartDate" SortExpression="StartDate" UniqueName="StartDate"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="DueDate" DataType="System.DateTime" HeaderText="DueDate" SortExpression="DueDate" UniqueName="DueDate"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="CompletionDate" DataType="System.DateTime" HeaderText="CompletionDate" SortExpression="CompletionDate" UniqueName="CompletionDate"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ActualDuration" DataType="System.Single" HeaderText="ActualDuration" SortExpression="ActualDuration" UniqueName="ActualDuration"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ActualUnitTypeId" DataType="System.Int32" HeaderText="ActualUnitTypeId" SortExpression="ActualUnitTypeId" UniqueName="ActualUnitTypeId"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="EstimatedDuration" DataType="System.Single" HeaderText="EstimatedDuration" SortExpression="EstimatedDuration" UniqueName="EstimatedDuration"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="DurationUnitTypeId" DataType="System.Int32" HeaderText="DurationUnitTypeId" SortExpression="DurationUnitTypeId" UniqueName="DurationUnitTypeId"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="PercentComplete" DataType="System.Byte" HeaderText="PercentComplete" SortExpression="PercentComplete" UniqueName="PercentComplete"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="EscalationLevelId" DataType="System.Int32" HeaderText="EscalationLevelId" SortExpression="EscalationLevelId" UniqueName="EscalationLevelId"> </telerik:GridBoundColumn> <telerik:GridCheckBoxColumn DataField="Archived" DataType="System.Boolean" HeaderText="Archived" SortExpression="Archived" UniqueName="Archived"> </telerik:GridCheckBoxColumn> <telerik:GridBoundColumn DataField="CreatedDateTime" DataType="System.DateTime" HeaderText="CreatedDateTime" SortExpression="CreatedDateTime" UniqueName="CreatedDateTime"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="CreatedById" DataType="System.Int32" HeaderText="CreatedById" SortExpression="CreatedById" UniqueName="CreatedById"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="LastUpdatedDateTime" DataType="System.DateTime" HeaderText="LastUpdatedDateTime" SortExpression="LastUpdatedDateTime" UniqueName="LastUpdatedDateTime"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="LastUpdatedById" DataType="System.Int32" HeaderText="LastUpdatedById" SortExpression="LastUpdatedById" UniqueName="LastUpdatedById"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="RemainingDuration" DataType="System.Single" HeaderText="RemainingDuration" SortExpression="RemainingDuration" UniqueName="RemainingDuration"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="RemainingUnitTypeId" DataType="System.Int32" HeaderText="RemainingUnitTypeId" SortExpression="RemainingUnitTypeId" UniqueName="RemainingUnitTypeId"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ReleaseId" DataType="System.Int32" HeaderText="ReleaseId" SortExpression="ReleaseId" UniqueName="ReleaseId"> </telerik:GridBoundColumn> </Columns></MasterTableView> </telerik:RadGrid> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="select * from incidents where incidentid >1500"> </asp:SqlDataSource> </form></body></html><telerik:RadGrid Skin="Vista" ID="GrigliaProgetti" runat="server" Width="500px" Height="400px" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true"> <PagerStyle Mode="NextPrevAndNumeric" /> <GroupingSettings CaseSensitive="false" /> <MasterTableView TableLayout="Fixed" > <Columns> <telerik:GridNumericColumn HeaderText="Project Id"/> <telerik:GridBoundColumn HeaderText="Project name"/> </Columns> </MasterTableView> </telerik:RadGrid> function onCheckBoxClick(chk) {
var combo = $find("<%= rcbDocType.ClientID %>");
//holds the text of all checked items
var text = "";
//holds the values of all checked items
var values = "";
//get the collection of all items
var items = combo.get_items();
//enumerate all items
for (var i = 0; i < items.get_count(); i++) {
var item = items.getItem(i);
//get the checkbox element of the current item
var chk1 = $get(combo.get_id() + "_i" + i + "_cbItem");
if (chk1.checked) {
if (text == "") {
text = item.get_text();
}
else {
text = "[Multi]";
}
values += item.get_value() + ",";
}
}
//remove the last comma from the string
values = removeLastComma(values);
if (text.length > 0) {
//set the text of the combobox
combo.set_text(text);
}
else {
//all checkboxes are unchecked
//so reset the controls
combo.set_text("");
}
}
//this method removes the ending comma from a string
function removeLastComma(str) {
return str.replace(/,$/, "");
}
function StopPropagation(e) {
//cancel bubbling
e.cancelBubble = true;
if (e.stopPropagation) {
e.stopPropagation();
}
}
<telerik:GridTemplateColumn HeaderText="Style" UniqueName="STYLE"> <ItemTemplate> <asp:DropDownList runat="server" ID="ddl_style" AppendDataBoundItems="true" AutoPostBack="true" > <asp:ListItem Text="a" Value="1"></asp:ListItem> <asp:ListItem Text="b" Value="2"></asp:ListItem> <asp:ListItem Text="c" Value="3"></asp:ListItem> </asp:DropDownList> </ItemTemplate></telerik:GridTemplateColumn>Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound If TypeOf e.Item Is GridDataItem Then Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) Dim ddl As DropDownList = DirectCast(item("STYLE").FindControl("ddl_style"), DropDownList) ddl.SelectedValue = ViewState("styleId") ddl.DataBind() End IfEnd Sub// load address types for the related combo function SetAddressCombo(){ var grid = $find("<%=RadContactMailings.ClientID %>"); var combo = grid.get_masterTableView().get_dataItems()[g_lastRowIndex].findControl("RadCmbAddressType"); combo.clearItems(); $.each(g_addrType, function(i) { var comboItem = new Telerik.Web.UI.RadComboBoxItem(); var text = g_addrType[i].substring(0, g_addrType[i].indexOf("=")); var value = g_addrType[i].substring(g_addrType[i].indexOf("=")); comboItem.set_text(text); comboItem.set_value(value); combo.get_items().add(comboItem); }); } <telerik:GridTemplateColumn UniqueName="AddressType" HeaderText="Address Type"> <ItemTemplate></ItemTemplate> <EditItemTemplate> <telerik:RadComboBox runat="server" ID="RadCmbAddressType" width="99%" MaxDropDownItems="25" DataSource='<%# (new string[] {Eval("Address.Type").ToString()}) %>' CollapseAnimation-Type="None" ExpandAnimation-Type="None" Skin="WebBlue" OnClientBlur="OnAddressTypeClientBlur" OnClientFocus="OnAddressTypeFocus" OnClientDropDownOpened="OnAddressTypeOpened" > </telerik:RadComboBox> </EditItemTemplate> </telerik:GridTemplateColumn>| <%@ Page Language="C#" %> |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <script runat="server"> |
| </script> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head runat="server"> |
| <title></title> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <telerik:RadScriptManager ID="RadScriptManager1" Runat="server"> |
| </telerik:RadScriptManager> |
| <telerik:RadComboBox ID="RadComboBox1" runat="server" Width="60" DropDownWidth="60" Skin="Default" Label="Label"> |
| <Items> |
| <telerik:RadComboBoxItem runat="server" Text="item1" Value="1" /> |
| <telerik:RadComboBoxItem runat="server" Text="item2" Value="2" /> |
| <telerik:RadComboBoxItem runat="server" Text="item3" Value="3" /> |
| </Items> |
| </telerik:RadComboBox> |
| </form> |
| </body> |
| </html> |