Dropdowns
Jul 3, 2007
I am trying to filter data on a report by using drop downs. I have been able to create the drop downs, however I can only get one to actually filter content. I need to allow users to select the group from drop down one, and then a different group from drop down 2 so the end result will only display informaiton that matches both drop downs.
Any suggestions will be appreciated. Below is the code if needed
<SqlVariable name="V_Queue" display="Queue :" type="dbselect" displaycolumn="display" datacolumn="group_name" default="%">
<SelectQuery mssql="true" oracle="false" db2="false">
<![CDATA[ SELECT group_name, group_name AS display FROM table_1 WHERE group_name like '%cat1%' UNION SELECT '%' AS group_name, 'All' AS display ]]>
</SelectQuery>
</SqlVariable>
<SqlVariable name="Group" display="Group :" type="dbselect" displaycolumn="display" datacolumn="group_name" default="%">
<SelectQuery mssql="true" oracle="false" db2="false">
<![CDATA[ SELECT group_name, group_name AS display FROM table_1 WHERE group_name like '%group%' UNION SELECT '%' AS group_name, 'All' AS display ]]>
</SelectQuery>
</SqlVariable>
View 1 Replies
Feb 27, 2006
Hi:
I have two drop downs bound to the same data source.. These dropdowns are automatically populated from a database. When I click the button I get some sort of strange query error.
Not sure what I'm doing wrong here.
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<script language="VB" runat="server">
Dim sOrderby as String
Dim sDirection as String
Dim MySQL As String
Dim MySQL1 As String
Dim sSubject As String
Dim sCategory As String
Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)
If Not Page.IsPostBack Then
Dim strConn As String = "server=GAALP-DT-UHABB2CFW;uid=sa;pwd=removed;database=NetG"
Dim MySQL As String = "Select DISTINCT [Subject] from dbo_v_netG_courses"
Dim MySQL1 As String = "Select DISTINCT [Category] from dbo_v_netG_courses"
Dim MyConn As New SqlConnection(strConn)
Dim objDR As SqlDataReader
Dim Cmd As New SqlCommand(MySQL, MyConn)
Dim Cmd1 As New SqlCommand(MySQL1, MyConn)
MyConn.Open()
objDR = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
ddl.DataSource = objDR
ddl.DataValueField = "Subject"
ddl.DataTextField = "Subject"
ddl.DataBind()
MyConn.Close()
MyConn.Open()
ddlDir.DataSource = Cmd1.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
ddlDir.DataValueField = "Category"
ddlDir.DataTextField = "Category"
ddlDir.DataBind()
MyConn.Close()
ddl.Items.Insert(0, "-- Choose --")
ddlDir.Items.Insert(0, "-- Choose --")
End If
'ddl.Items.Insert(0, "-- Choose --")
End Sub
' Sub Page_Change(ByVal sender As Object, ByVal e As DataGridPageChangedEventArgs)
' MyDataGrid.CurrentPageIndex = e.NewPageIndex
' BindData()
'Sub GridOne(ByVal Source As Object, ByVal E As EventArgs)
' MyDataGrid.CurrentPageIndex = 0
'End Sub
'Sub GetData(ByVal Source As Object, ByVal E As EventArgs)
' BindData()
' End Sub
Sub BindData(ByVal Source As Object, ByVal E As EventArgs)
sSubject = ddlDir.SelectedItem.Text
sCategory = ddlDir.SelectedItem.Value
Dim strConn As String = "server=GAALP-DT-UHABB2CFW;uid=sa;pwd=removed;database=NetG"
If sSubject = "" And sCategory = "" Then
MySQL = "Select * from dbo_v_netG_courses"
Else ( THIS LINE IS GIVING ME THE ERROR)
MySQL = "Select * from dbo_v_netG_courses where [Subject] = & sSubject"
End If
Dim MyConn As New SqlConnection(strConn)
Dim ds As DataSet = New DataSet()
Dim Cmd As New SqlDataAdapter(MySQL, MyConn)
Cmd.Fill(ds, "dbo_v_netG_courses")
MyDataGrid.DataSource = ds.Tables("dbo_v_netG_courses").DefaultView
MyDataGrid.DataBind()
End Sub
</script>
<html>
<head>
<meta name="GENERATOR" Content="ASP Express 3.0">
<title>Ad Hoc Sorting with a DataGrid</title>
</head>
<body>
<Form id="form1" runat="server">
<table>
<tr>
<td align="Left" valign="Top"><b><i>View Employee Data</i></b></td>
<td align="right" valign="Top">
Subject: <asp:dropdownlist id="ddl" runat="server">
</asp:dropdownlist>
Category: <asp:dropdownlist id="ddlDir" runat="server">
</asp:dropdownlist><br />
<br />
<asp:Button id="btn1" Text="View Records" onclick="BindData" runat="server" /><br />
</td>
</tr>
<tr>
<td align="Left" valign="Top" Colspan="2">
<asp:Datagrid runat="server"
Id="MyDataGrid"
GridLines="Both"
cellpadding="0"
cellspacing="0"
Headerstyle-BackColor="#8080C0"
Headerstyle-Font-Bold="True"
Headerstyle-Font-Size="12"
BackColor="#8080FF"
Font-Size="10"
AlternatingItemStyle-BackColor="#EFEFEF"
AlternatingItemStyle-Font-Size="10"
BorderColor="Black">
</asp:DataGrid><br> </td>
</tr>
</table>
</form>
</body>
</html>
View 2 Replies
View Related
Feb 13, 2007
Hi guys,
just a simple question here: i have some input parameters on my report that are datetimes (i.e. the user gets the date picker to select the date), if i want to use that parameter in a MDX statement what will it look like? IOW would today's date look like the string "13/02/07", or would i be expecting a string like this: "2007/02/13 00:00"?
I am looking to convert some dropdowns that contain dates extracted from a cube heirarchy with the datepickers so i need to know what i have to change in the MDX to accomodate this.
I also filter the dates that appear in the current dropdowns, is there a way to do this with the datepickers (maybe by pointing them to a dataset of dates extracted from the cube)?
Thanks!
sluggy
View 3 Replies
View Related
May 27, 2007
I’m using a SQLDataSource to populate a dropdown. The SQL table I use to populate the drop down has two columns. I only want one of them to be displayed in the drop down but I need to make decisions later in the code based on both columns. How do I access that second column in the datasource?
View 4 Replies
View Related
Nov 23, 2007
Hi All,
I have literally spent the last 2 1/2 hours troubleshooting an issue where I pass a parameter to the page and based on the parameter it runs a SQL statement and fills in the fields on the form. It is giving me the error message below but I know its not a NULL value and I know those controls are named correctly.
System.NullReferenceException: Object reference not set to an instance of an object.All of my textboxes and labels that are being populated are working fine when I comment out the dropdowns, I have this working on other pages but the only thing that is different here is I am using some AJAX (Autocomplete, Collapsable Panel and Calendar Control).
If I add a label or a textbox field on the form and take the same value that is going to populate the dropdownlist and populate the new control it works, so i know I'm getting the data and its not null/nothing. I also verified that the parameter is working correctly.
Any help will be a blessing, its probably something write under my nose!Thanks in advance!Tim
Here is the codeDim conn As SqlConnectionDim comm As SqlCommandDim reader As SqlDataReaderDim connectionstring As String = ConfigurationManager.ConnectionStrings("MagicDEV").ConnectionStringDim SeqIncident As Integer = Convert.ToInt16(Request.QueryString("NAME"))
If SeqIncident > 0 Thenconn = New SqlConnection(connectionstring)comm = New SqlCommand("Select isnull(t.[Sequence],'') as SeqIncident, " & _"isnull(t.Client,'') as SeqClient, " & _"isnull(c.Client,'') as Client, " & _"isnull(t.[Open By],'') as SeqOpenBy, " & _"isnull(p.[Code],'') as OpenedBy, " & _"isnull(t.[Sent To],'') as SeqAssignedTo, " & _"isnull(p1.code,'') as AssignedTo, " & _"isnull(t.[Date Open],'') as DateOpen, " & _"isnull(t.[Closed On],''), " & _"isnull(t.[Closed By],'') as SeqClosedBy, " & _"isnull(p2.[Code],'') as ClosedBy, " & _"isnull(t.[Seq_Severity:],'') as SeqUrgency, " & _"isnull(s.[Name],'') as Urgency, " & _"isnull(t.[Seq_UdStatus:],'') as SeqStatus, " & _"isnull(u.[id],'') as Status, " & _"isnull(t.Contact_Type,'') as ContactType, " & _"isnull(t.Ctrpart,'') as SeqAsset, " & _"isnull(i.[Asset#],'') as Asset, " & _"isnull(t.seq_rpt_party,'') as SeqRptParty, " & _"isnull(c1.client,'') as RptParty, " & _"isnull(t.Whiteboard_ID,'') as SeqWhiteboard, " & _"isnull(w.Whiteboard_ID,'') as Whiteboard, " & _"isnull(t.Subject,'') as SeqSubject, " & _"isnull(s1.[Description],'') as Subject, " & _"isnull(t.[Description],'') as IncDescription, " & _"isnull(t.Resolution,'') as IncResolution, " & _"isnull(t.[FCR:],'') as FCC, " & _"isnull(t.Sent_Ack,'') as SentAck, " & _"isnull(t.Inc_Closed,'') as IncClosed, " & _"isnull(t.RC,'') as RC " & _
"From _Smdba_._Telmaste_ t " & _"inner join _Smdba_._Customer_ c on t.client = c.[Sequence] " & _
"left outer join _Smdba_._Personnel_ p on t.[open by] = p.[Sequence] " & _"left outer join _Smdba_._Personnel_ p1 on t.[Sent To] = p1.[Sequence] " & _
"left outer join _Smdba_._Personnel_ p2 on t.[Closed By] = p2.[Sequence] " & _"left outer join _Smdba_._Severity_ s on t.[Seq_Severity:] = s.[Sequence] " & _
"left outer join _Smdba_._UdStatus_ u on t.[Seq_UdStatus:] = u.[Sequence] " & _"left outer join _Smdba_._Inventor_ i on t.[Ctrpart] = i.[Sequence] " & _
"left outer join _Smdba_._Customer_ c1 on t.seq_rpt_party = c1.[Sequence] " & _"left outer join _Smdba_._Whiteboard_ w on t.Whiteboard_ID = w.[Sequence] " & _
"left outer join _Smdba_._Subjects_ s1 on t.Subject = s1.[Sequence] " & _"Where t.Sequence = @Sequence1", conn)
comm.Parameters.Add("@Sequence1", Data.SqlDbType.Int)
comm.Parameters.Item("@Sequence1").Value = SeqIncident
Try
conn.Open()
reader = comm.ExecuteReader()
reader.Read()ClientDropDown.SelectedItem.Text = reader.Item("Client")
ClientDropDown.SelectedItem.Value = reader.Item("seqclient")
Finallyconn.Close()End TryEnd If
View 2 Replies
View Related
Jan 24, 2007
I built a very simple report which uses a query to define the options in the parameter€™s dropdown. I used that same dataset to define the default for that parameter (meaning that it will just pick the first row from the dataset and use that as the default). When I run the report watching a Profiler trace on the SQL database, it runs that query twice. (Presumably, that€™s once to fill the dropdown list and once to figure out the default.) That seems silly to me since it is the same query that is the same dataset in Reporting Services. Is there any way around this? My parameter bar is rendering twice as slowly as it should be.
I've tested against SSRS 2005 SP1 and the CTP of SP2.
View 2 Replies
View Related
Aug 29, 2007
I have one page, one connection, and three dropdowns. The connection looks like (as an example):<asp:SqlDataSource ID="DropDownConn" runat="server" ConnectionString="<%$ ConnectionStrings:aousConnectionString %>" SelectCommand="SELECT [Value], [Text] FROM [DropDown] WHERE (([Group] = @Group) AND ([Viewable] = @Viewable))"> <SelectParameters> <asp:Parameter Name="Group" Type="String" /> <asp:Parameter DefaultValue="True" Name="Viewable" Type="Boolean" /> </SelectParameters></asp:SqlDataSource>
The DropDowns Look like this:
<asp:DropDownList ID="DropDown1" runat="server"></asp:DropDownList><asp:DropDownList ID="DropDown2" runat="server"></asp:DropDownList><asp:DropDownList ID="DropDown3" runat="server"></asp:DropDownList>The C# Code I am trying is like this:DropDownConn.SelectParameters["Group"].Equals("DropDown1");DropDownConn.SelectParameters["Viewable"].Equals(true);DropDown1.DataSourceID = "DropDownConn";DropDown1.DataTextField = "Text";DropDown1.DataValueField = "Value";DropDown1.DataBind();
As an example. I can not get it done so that I don't have to create 3 dataconnections. Any help, PLEASE?
View 2 Replies
View Related