I am trying to load a RadGrid based on the value inside the RadComboBox. I have tried a few things but can't quite get it to work. The user is supposed to select a value("email") from the RadComboBox and a RadGrid should be loaded onto the page. At the moment one of the PROCs have an email hard-coded so a grid is loaded onto the page which contains the data for that specific user. I also have a variation of that PROC that is supposed to change the RadGrid whenever the user selects a different email, but I can't get it to work. Once the user selects an email they will see a grid which contains the Customer Number, if they click the Customer Number they will see a drop down which contains the number along with an error message.
I have attached the aspx, .cs, PROCs, and a photo of what the page looks like with one hard-coded existing email from the RadComboBox.
I have attached the aspx, .cs, PROCs, and a photo of what the page looks like with one hard-coded existing email from the RadComboBox.
4 Answers, 1 is accepted
0
Brett
Top achievements
Rank 1
answered on 21 Mar 2014, 02:41 AM
<%@ Page Title="Report" Language="C#" MasterPageFile="~/MasterPages/Site.Master" AutoEventWireup="true" CodeBehind="Report2.aspx.cs" Inherits="Report2" Theme="Default" %><asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server"> <asp:Panel ID="Panel1" runat="server"> <br /> <table> <tr> <td> <asp:Label ID="LblEmail" runat="server" Text="Email: "></asp:Label> </td> <td> <telerik:RadComboBox ID="RcbEmail" runat="server" DataSourceID="SqlDsEmail1" DataTextField="EMAIL" DataValueField="EMAIL" AutoPostBack="True" Width="250px" EmptyMessage="- Select User -" onselectedindexchanged="RcbEmail_SelectedIndexChanged"></telerik:RadComboBox> </td> </tr> </table> <table cellspacing="0" cellpadding="0" style="border: 1px solid #808080"> <tr> <td> <asp:PlaceHolder ID="phReport" runat="server" /> </td> </tr> </table> </asp:Panel> <br /> <telerik:RadAjaxManager ID="ramMain" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="grdReport"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="grdReport" LoadingPanelID="rlpmain"></telerik:AjaxUpdatedControl> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="rlpmain" runat="server"> </telerik:RadAjaxLoadingPanel> <telerik:RadGrid ID="grdReport" runat="server" DataSourceID="grdReportDataSource" AutoGenerateColumns="False" AllowSorting="True" ShowFooter="true" AllowMultiRowSelection="False" AllowPaging="false" GridLines="None" ShowGroupPanel="false" EnableLinqExpressions="false" > <PagerStyle AlwaysVisible="True" Mode="NextPrevNumericAndAdvanced" Position="TopAndBottom" /> <MasterTableView DataSourceID="grdReportDataSource" AllowMultiColumnSorting="false"> <NestedViewTemplate> <asp:Panel runat="server" ID="InnerContainer" Visible="true" ViewStateMode="Enabled"> <telerik:RadTabStrip runat="server" ID="tsMain" MultiPageID="mpMain" SelectedIndex="0"> <Tabs> <telerik:RadTab runat="server" Text="Number" PageViewID="pvMain" /> </Tabs> </telerik:RadTabStrip> <telerik:RadMultiPage runat="server" ID="mpMain" SelectedIndex="0" RenderSelectedPageOnly="false"> <telerik:RadPageView runat="server" ID="pvMain"> <asp:Label ID="lblNUM" Font-Bold="true" Font-Italic="true" Text='<%# Eval("NUM") %>' Visible="false" runat="server"></asp:Label> <telerik:RadGrid runat="server" ID="grdOrders" DataSourceID="grdReportDataSource2" ShowFooter="false" AllowSorting="false" EnableLinqExpressions="false"> <PagerStyle AlwaysVisible="True" Mode="NextPrevNumericAndAdvanced" Position="Bottom" /> <MasterTableView ShowHeader="true" AutoGenerateColumns="False" AllowPaging="False"> <Columns> <telerik:GridBoundColumn DataField="NUM" DataType="System.Decimal" FilterControlAltText="Filter NUM column" HeaderText="Number" SortExpression="NUM" UniqueName="NUM"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ERRORMSG" FilterControlAltText="Filter ERRORMSG column" HeaderText="Error Message" SortExpression="ERRORMSG" UniqueName="ERRORMSG"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="DATEADDED" DataType="System.DateTime" FilterControlAltText="Filter DATEADDED column" HeaderText="Date Added" SortExpression="DATEADDED" UniqueName="DATEADDED"> </telerik:GridBoundColumn> </Columns> </MasterTableView> </telerik:RadGrid> <asp:SqlDataSource ID="grdReportDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="dbo.sp_ReportNested2" SelectCommandType="StoredProcedure" > <SelectParameters> <asp:ControlParameter ControlID="lblNUM" PropertyName="Text" Type="String" Name="NUM"></asp:ControlParameter> </SelectParameters> </asp:SqlDataSource> </telerik:RadPageView> </telerik:RadMultiPage> </asp:Panel> </NestedViewTemplate> <Columns> <telerik:GridBoundColumn DataField="NUM" FilterControlAltText="Filter NUM column" HeaderText="Number" SortExpression="NUM" UniqueName="NUM"> </telerik:GridBoundColumn> </Columns> <PagerStyle AlwaysVisible="True" Mode="NextPrevNumericAndAdvanced" Position="TopAndBottom" /> </MasterTableView> <ClientSettings AllowDragToGroup="false"> </ClientSettings> </telerik:RadGrid> <asp:SqlDataSource ID="grdReportDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="dbo.sp_ReportHeader2" SelectCommandType="StoredProcedure" > </asp:SqlDataSource> <asp:SqlDataSource ID="SqlDsEmail" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="sp_ReportHeader2" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:Parameter Name="email" Type="String" /> </SelectParameters> </asp:SqlDataSource> <asp:SqlDataSource ID="SqlDsEmail1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT DISTINCT EMAIL FROM ProductCentral.dbo.Log"> </asp:SqlDataSource></asp:Content>//code behind
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using Telerik.Web.UI;namespace EE.Intranet.Reporting{ public partial class ClientAuditReport2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //grdReportDataSource.SelectParameters.Add("Email", RcbEmail.SelectedValue); } protected void grdReport_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) { if (e.Item is GridEditableItem && e.Item.IsInEditMode) { GridEditableItem edit = (GridEditableItem)e.Item; RadDropDownList ddl = (RadDropDownList)edit.FindControl("RadDDLEmail"); ddl.SelectedValue = (string)DataBinder.Eval(e.Item.DataItem, "EMAIL").ToString(); } } protected void RcbEmail_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e) { //grdReportDataSource.SelectParameters.Clear(); //grdReportDataSource.SelectParameters.Add("Email",RcbEmail.SelectedValue); } }}//PROCs
USE [intranet]GO/****** Object: StoredProcedure [dbo].[ReportHeader2] Script Date: 3/20/2014 2:25:31 PM ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[sp_ReportHeader2]ASBEGIN SELECT DISTINCT CUSTNUM FROM ProductCentral.dbo.Log WHERE EMAIL = 'brett@yahoo.com 'END--this may be what I need to use to load the radGrid dynamically based on the emailUSE [intranet]GO/****** Object: StoredProcedure [dbo].[sp_ReportHeader2] Script Date: 3/20/2014 2:25:31 PM ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[sp_ReportHeader2]@email varchar(100)ASBEGIN SELECT DISTINCT CUSTNUM FROM ProductCentral.dbo.Log WHERE EMAIL = @emailENDUSE [intranet]GO/****** Object: StoredProcedure [dbo].[sp_ReportNested2] Script Date: 3/20/2014 2:25:34 PM ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[sp_ReportNested2]@CUSTNUM intASBEGINSELECT CUSTNUM, ERRORMSG, DATEADDED FROM ProductCentral.dbo.Log WHERE CUSTNUM = @CUSTNUMEND0
Hi Brett,
Thank you for the provided code. I will test it locally and will get back to you with additional information / suggestions.
Regards,
Pavlina
Telerik
Thank you for the provided code. I will test it locally and will get back to you with additional information / suggestions.
Regards,
Pavlina
Telerik
Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.
0
Brett
Top achievements
Rank 1
answered on 26 Mar 2014, 03:56 PM
Thank you for your help. I was able to get this working (although I don't know if I used the most efficient way, still works fine though).
0
Hello Brett,
I am glad to hear that you have managed to get this working alone. Please do not hesitate to contact us if other questions or problems arise. We would be happy to help you.
Regards,
Pavlina
Telerik
I am glad to hear that you have managed to get this working alone. Please do not hesitate to contact us if other questions or problems arise. We would be happy to help you.
Regards,
Pavlina
Telerik
Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.