Changing Parameter In SQLDataSource For Multiple DropDowns
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
ADVERTISEMENT
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
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
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
Aug 21, 2006
I have a gridview bound to an ObjectDataSource, which is a dataset populated by SQL queries. The gridview works with the default SelectMethod configured in the ObjectDataSource. I would like to be able to change the SelectMethod based on user input, which would call a different query. I have one textbox for input and several buttons to pick the type of filter.
My gridview populates on with the default selectmethod if I create a button that does nothing but a postback. My other buttons run the following codes which returns nothing. Any ideas what I'm doing wrong?
If e.CommandArgument = "Last_Name" Then
EmployeeData.SelectMethod = "GetDataByLastName"
End If
If e.CommandArgument = "First_Name" Then
EmployeeData.SelectMethod = "GetDataByFirstName"
End If
gvPhoto.DataSourceID = EmployeeData.ID
gvPhoto.DataBind()
Thanks.
Lisa
View 1 Replies
View Related
Mar 15, 2008
I know i can accomplish this by setting a session variable on page load on the server side (Session["UserName"]= User.Identity.Name) and then use a session parameter, but I was wondering how to do it without using session variables, i was hoping the following code would work, but it doesn't. Thanks for any ideas.
" Name="UserName" Type="String" />
View 3 Replies
View Related
May 19, 2008
I cant seen to change the Select command for a SQL Datasourcetry #1 SqlDataSourceProfilesThatMatch.SelectCommand = strSQLForSearch SqlDataSourceProfilesThatMatch.SelectParameters("ProfileID").DefaultValue = pProfileID SqlDataSourceProfilesThatMatch.SelectParameters("LoggedInUsersZipcode").DefaultValue = pUsersZipCode SqlDataSourceProfilesThatMatch.SelectParameters("ZipDistance").DefaultValue = pDistance
NewProfilesThatMatchGridView.DataBind()
try #2 SqlDataSourceProfilesToBeMatched.SelectParameters.Clear() SqlDataSourceProfilesThatMatch.SelectCommand = strSQLForSearch SqlDataSourceProfilesThatMatch.SelectParameters.Add("ProfileID", pProfileID) SqlDataSourceProfilesThatMatch.SelectParameters.Add("LoggedInUsersZipcode", pUsersZipCode) SqlDataSourceProfilesThatMatch.SelectParameters.Add("ZipDistance", pDistance)
NewProfilesThatMatchGridView.DataBind()
No errors but no rows show in the gridview. If I debug and get the value strSQLForSearch and paste it into a new SQL query window I get results.
Any ideas????
Thanks
View 3 Replies
View Related
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
View Related
May 2, 2007
I have 2 datasets for a report and I want to use a field from the first dataset to set a parameter value in the second dataset.
I am using the Report Parameters window to do this.
I set the parameter as hidden and then Non-queried setting the value to the field in the first dataset. I get an error stating that fields cannot be used in report parameter expressions.
So I tried to use the From query option. I selected the first dataset and then the value and label fields. I also set the default values to the same values.
The problem is that the parameter always has the same value which is the first record in the first dataset. How do I get the parameter to populate with the other values as the report runs?
Thanks
View 1 Replies
View Related
Jun 16, 2007
I have inherited a web site from another developer. I am new to .net programming. Anyway I have had to add a parameter to an sql procedure and I thought i had made the change in the business logic layer correctly. I am using gridview to display and export to an excel spreadsheet. After my changes my page lets me select my parameters, but now my page come up blank, no error messages the only thing on the page are the save and export buttons.
Please help what have i missed.
Steve
View 1 Replies
View Related
Jan 22, 2008
This is probably a simple question, but I have a form with two content windows. In content1 using an sqldatsource1 I select a single record and display it using a FormView.
What I need to do is using one field from sqldatsource1 ("CategoryName", which is not displayed in formview1), in content window 2; I need to display all records with the same CategoryName.
So the simple English version is:
Using CategoryName from SqlDataSource1 (in content window 1), select all records in SqlDatasource2 where CategoryName is = CategoryName (in content window 2).
I am using vb code behind.
Thanks
View 1 Replies
View Related
Mar 2, 2008
I have a SqlDataSource, a GridView and a TextBox (whose ID is searchTB) on my page. I can use the SqlDataSource like this:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="Data Source=TORNADO;Initial Catalog=AdventureWorks;Integrated Security=True"
ProviderName="System.Data.SqlClient"
SelectCommand="select * from production.product where name = @nameparam">
<SelectParameters>
<asp:ControlParameter ControlID="searchTB" Name="nameparam"
PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource>
However, I want the search to be made using the LIKE operator, ie, select * from production.product where name LIKE %THE_TEXT_FROM_TEXTBOX%.
How can I do this? Thanks
View 5 Replies
View Related
Mar 31, 2008
Hi there,
I'm still new, so please be patient with me...
I am using C# ASP.NET 2.0. I have a web page that uses a Calendar control to display links for events from my database. The links use the __doPostBack to pass the EventID back to the same page. I was getting the EventID as a string okay and then passing it into a TextBox control. I then had an SqlDataSource control that set to display the Event in a DetailsView. The SqlDataSource uses a control to get the EventID - I used the TextBox control. It is all working fine, but...
What I want to do is instead of using a TextBox control - pass the string in to a public property in the class in my code-behind. I want to use an <asp:Parameter> on my SqlDataSource control to set the control to get the EventID from my public property. How do I do this?
Thanks in advance.
View 3 Replies
View Related
Jun 3, 2008
I have a gridview which is displaying a bunch of data. However, I'd only like to display data based on the query string. Here's my code: <asp:GridView ID="gv" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CssClass="GridControl" DataKeyNames="ID">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" Visible="false" SortExpression="ID" />
<asp:HyperLinkField DataNavigateUrlFields="ID" DataNavigateUrlFormatString="Details.aspx?id={0}" Text="Details" />
<asp:BoundField DataField="Name" HeaderText="Attendee" SortExpression="Name" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:conn %>" SelectCommand="sprocCUSTOM_GetDetail" SelectCommandType="StoredProcedure">
</asp:SqlDataSource>and my stored procedure: SELECT ID, Name, Email FROM Events WHERE (ID = @eventID) So as you can see, I need to get the value from the query string to add to my stored procedure. I know this can be done in the code-behind, but isn't there a way to add <SelectParameter> to the SqlDataSource? I just can't get the query string in there.
View 12 Replies
View Related
Jul 8, 2006
Hi
I am generating report with my datasource to an OLAP Cube. I have scenario that there are 2 dimension tables pointing to a single fact table. According to a user input, i have to use one dimension table and not the other and vice versa. I tried using IIF statement in the MDX query designer., but was facing errors.
First of all i want to know if this is possible and if yes, how?
Also , Is it possible to open a window form on clicking any report data
(Similar to assigning hyperlink, but i want to open a window form instead!!!)
regard
Sai
View 2 Replies
View Related
Jun 4, 2007
I am creating SSRS reports on top of SSAS cubes. I want the default value of parameter to change dynamically based on the current year or it should select the last of the parameter values.
Can this be done?
View 4 Replies
View Related
Mar 3, 2008
The report has many multi-valued parameter collection. Each parameter has its own dataset attached to it and each parameter has got a list of many values.
All parameters have a single default value dataset to return a DEFAULT value.
Now when the user selects value for each parameter, the reporting services takes times(atleast 5secs) to repaint/reload the whole page.
Could you please let me know how to resolve this.
thanks.
View 3 Replies
View Related
Aug 25, 2006
Hello all, This may be a simple question, but it is causing me some grief at the moment.I put a SqlDataSource control on my form, and pointed it to the stored procedures I had written to insert/update/delete rows in my database.The DataSource control notices that I am using parameters in my queries, and asks me to select where the parameters will be assigned from (Control, Form, Session, etc.)I am keeping the primary key value (in this case an ID number for a real estate listing) persisted in ViewState.Is there any way to access ViewState from the SqlDataSource control, or do I need to find another way to do this? Thanks,Adam
View 1 Replies
View Related
Nov 6, 2006
One of the requirements of the UpdateParameters for a GridView I'm building is that the fields that are being edited via EditItemTemplates are passed back to the UpdateParameter as XML. How would I go about combining the fields from the GridView/EditItems into an XML string that I can set as an asp:Parameter?
Thanks.
View 1 Replies
View Related
Feb 28, 2007
I'm trying to pass my SqlDataSource a parameter that is defined in the code-behind file for the same page. I've tried the method below but it does not work. Is there a better way?SubmitForm.ascx page: <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ connection string...... %>" SelectCommand="sp_CourseMaterialShipment_GetCourses" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:Parameter DefaultValue="<% ProgramID %>" Name="programID" Type="Int32" /> </SelectParameters></asp:SqlDataSource> SubmitForm.ascx.vb page:Private ProgramID as string = "25"Public ReadOnly Property ProgramID() As String Get Return _ProgramID End GetEnd Property ThanksJason
View 2 Replies
View Related
May 4, 2007
Hi,
In the SqlDataSource control if I go to the SelectQuery property and I set one parameter with the “direction� property to “Output� the result doesn’t display in the control, why?
Points:
The procedure witch is in the selectquery property the parameter in it is set to output two.
View 3 Replies
View Related
Jun 14, 2007
I need to know how to setup the ControlParameter for a template control in my Gridview? I have a datepicker in my template and I need to know how to refer to it in the ControlParameter of the SQLDataSource control.
<UpdateParameters>
<asp:ControlParameter Name="dp_start" ControlID="bdpPlanStart" PropertyName="SelectedValue" Type="Datetime" /> Here is the template:<asp:TemplateField HeaderText="Start" SortExpression="dp_start">
<ItemTemplate>
<%#DataBinder.Eval(Container, "DataItem.dp_start", "{0:d}")%>
</ItemTemplate>
<EditItemTemplate>
<BDP:BasicDatePicker id="bdpPlanStart" SelectedValue='<%# DataBinder.Eval(Container.DataItem,"dp_start") %>' runat="server" DateFormat="d">
</BDP:BasicDatePicker>
</EditItemTemplate>
</asp:TemplateField>
View 1 Replies
View Related
Jul 2, 2007
I have a table with with some column name includes a space. for example [Product ID] [Product Name] Instead of Product_ID, Product_Name. when I try to create a gridview and enable delete, insert. It just won't work.
I've been trying for several hours without success. When I click on delete. the page postback without any error, but the record doesn't get deleted or updated.
<asp:SqlDataSource id="sourceProducts" runat="server" SelectCommand="SELECT [Product ID], [Product Name] FROM Products" ConnectionString="<%$ ConnectionStrings:mydb %>"DeleteCommand="Delete from Products where [Product ID]=@ProductIDUpdateCommand="UPDATE Products SET [Product Name]=@ProductName WHERE [Product ID]=@ProductID" > <UpdateParameters> <asp:Parameter Name="ProductName" /> <asp:Parameter Name="ProductID" /> </UpdateParameters> <DeleteParameters> <asp:Parameter Name="ProductID" Type="Int32"/> </DeleteParameters></asp:SqlDataSource><asp:GridView ID="GridView2" runat="server" DataSourceID="sourceProducts" AutoGenerateColumns="False" DataKeyNames="Product ID" > <Columns> <asp:BoundField DataField="Product ID" HeaderText="ID" ReadOnly="True" /> <asp:BoundField DataField="Product Name" HeaderText="Product Name"/> <asp:CommandField ShowEditButton="True" ShowDeleteButton="True"></asp:GridView>
Another testing I did was to use another table with no space in the Column name, Product_ID, Product_Name. and I can't name my parameter as PID, PNAME. I have to name it as @Product_ID, @Product_Name in order for Delete, update to work. My understanding is if I declare the parameter explicitly(<asp:Parameter Name="PID" />, I can use any name I want. Did I must missed something?
I'm new to ASP.NET, could someone help me?
Thanks.
View 5 Replies
View Related
Jul 20, 2007
I'm sure that is really simple, but how do I pass a parameter with multiple value to a SQLdatasource?
ex: SELECT field1 from tblTableA where idTableA IN ( @Param1)
Let's say I want to pass 1,2,3,4 as Param1 (SELECT field1 from tblTableA where idTableA IN ( 1,2,3,4))
How I am supposed tu use the .SelectParameters.Add() to pass a list of integers instead of a single value??
Thanks in advance.
View 2 Replies
View Related
Dec 5, 2007
Is it possible to use a WHERE-IN statement with a SqlDataSource control. For instance:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
SelectCommand="SELECT [Id], [Name], [Phone] FROM [Table1] WHERE ([Id] IN @Id)">
<SelectParameters>
<asp:Parameter DefaultValue="( 1, 3, 5, 7, 11 )" Name="Id" Type="Int32" />
</SelectParameters></asp:SqlDataSource>
I'm hoping the gridview would then display a table with rows for records 1,3,5,7,11. Thanks for any help...
View 2 Replies
View Related
Jan 31, 2008
Hi there,I'm new to db stuffs and I'm using sqldatasource to pull my data from the server. Here's the codes.<asp:SqlDataSource ID="testSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:p01impConnectionString %>" SelectCommand="SELECT [a], [b], [c], [d], [e] FROM [MYDB] WHERE (([a] = @a) AND ([b= @b))" CancelSelectOnNullParameter="False"> <SelectParameters> <asp:ControlParameter ControlID="TextBox1" Name="a" PropertyName="Text" Type="String" /> <asp:ControlParameter ControlID="TextBox2" Name="b" PropertyName="Text" Type="String" /> </SelectParameters></asp:SqlDataSource> notice that I haven't used [c], [d], [e] and I want to declare a parameter, something like: Total = c + (d*e)can anyone show me the syntax to do this UNDER sqldatasource? I then will have to put that Total in a gridview (i can solve this part)Thanks
View 1 Replies
View Related
Dec 14, 2005
Problem: The system throws the following error"Procedure or Function 'sp_TestRequestFormMaster_StatusChange' expects parameter '@Status', which was not supplied."I'm using VS 2005 Final.Recreate the problem:I've created a simple stored procedure with two parameters on SQL 2005 on Win 2003 Server. @ID INT, & @Stutus INTOn a SQLDataSource Control for the Delete query, using the build button to open the Command and Parameter Editor, I click the Refresh Paramater.I set ID Parameter Source: Control, ControlID: GridView1I set Status Parameter Source: None, DefaultValue: 1001.Partial Source View:
<DeleteParameters><asp:ControlParameter ControlID="GridView1" Name="ID" propertyName="SelectedValue" Type="Int32" DefaultValue="" /> <asp:Parameter DefaultValue="1001" Name="Status" Type="Int32" /><asp:Parameter DefaultValue="" Direction="ReturnValue" Name="RETURN_VALUE" Type="Int32" /></DeleteParameters>I run the code, click the delete in the GridView and the error appears. How can I pass a status value without relating it to a source.
View 1 Replies
View Related
Jan 10, 2006
Hi, I am using a SQL DataSource with a few parameters. I need to specify the value of the parameters at run time but I need a custom way to do it as the value needs to be calculated not come from Cookie, Control, Form, Profile, QueryString or Session. Is there a way to bind your own value to these parameters. For instance if I had a variable how would I bind that to the parameter?
At the moment i am doing the following which works but I dont think it is the correct way
dsMyDataSource.SelectParameters["MyParameter"].DefaultValue = MyCalculatedValue;
In previous projects i have added a value to the Session and then bound the parameter value to the session but that doesnt seem like a good solution either.
Thanks for any help you can give.
Martin
View 9 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
Oct 19, 2007
I am currently creating a report with SQL Server Reporting Service 2005 and have run into an issue where the user can change the value in a drop down and the report will reload without any data. Data will not show untill the "View Report" button is clicked. Is there any way to avoid the page reloading like this so that the user is not confuesed by the lack of data ans just thinks that nothing was suppose to show up?
Thanks in advance.
View 4 Replies
View Related
Jan 21, 2008
Hi,
I have two input felds recieved date from and to fields. I would like to put one checkbox (not one for from field and one for to field) and when you tick the checkbox, I would like to disable both input fields indicating null values for both input fields.
Is it possible?? If yes, how to archieve that?
Thanks a lot in advance,
Leon
View 1 Replies
View Related
Aug 8, 2006
Hi, I have a little problem with a SqlDataSource.
A table in my database has an ID collumn, which is an integer auto-increment. The datasource has a SelectQuery with an [ID] parameter, which it retrieves from the querystring.
I want the DataSource to return all rows when no querystring parameter is passed, and when an ID is given via the querystring, a 'WHERE' clause in the SelectQuery would return only certain records.
However, suppose I have the following query:
SELECT * FROM SomeTable WHERE ([ID] = @ID)
When I bind @ID to the QueryString with '*' as DefaultValue, it throws an exception saying it can't convert '*' to a smallint, which makes sense.
I haven't got a clue how to solve this, except for using different DataSources based on the presence of the querystring parameter.
Any idea's?
View 7 Replies
View Related