.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

ObjectDataSource doesn't remove previously added Parameter

Posted By:      Posted Date: October 17, 2010    Points: 0   Category :ASP.Net


I use an objectdatasource programmatically to use a parameterless method when SearchWord variable is empty and a Search method with one parameter when SearchWord is not empty, the event I use is objectdatasource selecting so that I can adjust parameters conveniently, I have a problem here: I can add a new parameter and set its value but I can't remove a previously added parameter from objectdatasource selectparameters and an error raises because of this, this is the selecting method:

 Protected Sub objWebUploadLog_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles objWebUploadLog.Selecting

        If SearchWord = "" Then
            If objWebUploadLog.SelectParameters("search") Is Nothing Then

            End If
            objWebUploadLog.SelectMethod = "GetWebUploadLogByUserID"
            objWebUploadLog.SelectCountMethod = "GetWebUploadLogCountByUserID"
            If objWebUploadLog.SelectParameters("search") Is Nothing Then
                Dim param As WebControls.Parameter = New WebControls.Parameter("search", TypeCode.String)

View Complete Post

More Related Resource Links

ObjectDataSource CancelSelectOnNullParameter="false" // Select all when select parameter is null or


Hi ! I am using an objectdatasource in my project and I want to select all rows when the selectparameter value is empty ! I did the following but I am failling;
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DataObjectTypeName="TugberkUgurluCom_TransferModule.TransferPriceDetailsAll" SelectMethod="GetAllDataFromPricesForControl" TypeName="TugberkUgurluCom_TransferModule.TransferPriceDBComponent" UpdateMethod="UpdateTransferPrices">
    <asp:ControlParameter ConvertEmptyStringToNull="true" ControlID="DropDownList1" Name="TpDestID" PropertyName="SelectedValue" Type="

How To Remove a Query Parameter from a URL


for a string such as this:


how would I remove the parameter id 12?


Remove Previously Promoted Fields

I am having trouble removing previously promoted fields from my form library.   Scenario:   InfoPath 2007 SharePoint Server 2007 using Forms Services   I had published my infopath form as a content type and made that content type the default for this form library.  I then promoted several fields when I published the form and I gave them custom names in the publishing wizard.  I then changed the custom names when I published the next version of the form template (because I decided to call them something different).    The problem is that the old promoted field names are still showing in both the content type and the library along with the new names (I now have twice as many columns as I should have).  I was able to delete these extra columns from the content type but they still show up in the library.  When editing settings on the library, these columns are not editable (thier names are not clickable).  I have deleted all form instances from the library (thinking that maybe an old form instance that used the old names caused them to stick around) but that had no effect.    How on earth do I get rid of these columns that were created by field promotion?  I would rather not delete the entire form library because that means recreating my workflows that I have built on the library.

NULL label doesn't appear on drop down or multi-select parameter.

Hi, I am using SSRS 2005 SP3. I have the following query that I use for my parameter: SELECT 0 AS c1, 'NOT Specified' AS c2 UNION SELECT 1 AS c1, NULL AS c2 UNION SELECT 2 AS c1, 'Test 1' AS c2 UNION SELECT 3 AS c1, 'Test 2' AS c2 Let's call my parameter prm1. The type of prm1 is string and it has "Allow null value" and "Allow blank value" options ticked. C1 is the value field and C2 is the label field for prm1. When I preview the report, and I didn't see NULL in my drop down list,  but that record has been shown as 1 (which is the value). I am wondering if this is a normal behavior of SSRS? It's not a big deal. I can replace NULL with something else, but I am just curious. Cheers, Uzzie

Remove a dynamically added ListViewItem from a ListView

Good day, In my xaml I have created a window in my app which contains a  ListView control. I have programmatically added ListViewItems. The ListViewItems each contain a grid. Grid column 0 contains a textblock, Grid column 1 contains a textbox and Grid column 2 contains a button. What I would like to do is click the button in the ListViewItems grid, and remove the ListViewItem in the button is contained from the ListView. Could anyone suggest a way to do this? I would really appreciate any advice, as this is crucial to the feature I am creating.

Why request parameter added to client side code in each method while using svcutil.exe

Hi, I am using WCF services in my project and want to call WCF methods asynchronously. I am hosting WCF service programmatically in windows app as follows svc = New ServiceHost(GetType(Service1), New Uri("net.tcp://localhost:8806/")) Dim svcMDB As New ServiceMetadataBehavior svc.Description.Behaviors.Add(svcMDB) svc.AddServiceEndpoint(GetType(Service1), New NetTcpBinding(), "MyBusiness/MyBusinessService/") svc.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexTcpBinding(), "MyBusiness/MyBusinessService/mex") svc.Open() Me.Text = "Service started...." and I am generating client side proxy using svcutil.exe as follows. svcutil /n:net.tcp://localhost:8806/MyBusiness/MyBusinessService,MyService net.tcp://localhost:8806/MyBusiness/MyBusinessService/mex /a /language:vb   The result of this command is as :   Microsoft (R) Service Model Metadata Tool [Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.2152] Copyright (c) Microsoft Corporation.  All rights reserved.   Attempting to download metadata from 'net.tcp://localhost:8806/MyBusiness/MyBusi nessService/mex' using WS-Metadata Exchange. This URL does not support DISCO. Generating files... D:\Prabodh\New C2k\Test Projects\DataTableToArray\MyHost\bin\Debug\MyBusinessSer vice.vb D:

Parameter names ending with "specified" added to web service method call

Hello,I am new to WCF. I created a wcf web service and the generated web method exposed by wcf has some additional boolean parameters with names that end with "Specified".I am trying to understand why are these additional parameters necessary and how to get rid of them. Thanks!David

sp_send_dmail doesn't work in Agent job with query parameter


I have the following query which needs to run on a schedule and email a list of all disabled jobs for the SQL Server instance (I've changed the server and email names for privacy):

 EXEC msdb.dbo.sp_send_dbmail
 @recipients = N'name@email.com'
 ,@body = N'The attachment shows the names of all SQL jobs that are currently disabled on SERVER1'
 ,@subject = N'Disabled Jobs on SERVER1'
 ,@query = N'SELECT [NAME] FROM [msdb].[dbo].[sysjobs]'
 ,@attach_query_result_as_file = 1

This query works fine when running from a query window.  however, when I try to run it from a SQL Agent job, I get the following error on the step output (username changed for privacy):

Executed as user: domain\user. Error formatting query, probably invalid parameters [SQLSTATE 42000] (Error 22050). The step failed.

If I try other queries in the @query parameter, everything works fine when running from the job.  As soon as I try to query [msdb].[dbo].[sysjobs] though, the job fails.  I ran a profiler trace, and I found a more detailed error message that occurs during the execution of the job, unfortunately it involves an undocument SP:

exec sp_executesql N'EXECUTE msdb.dbo.sp_sqlagent_log_jobhistory @job_id = @P1, @step_id = @P2, @sql_message_id = @P3, @sql_severity = @P4, @run_status

Button in Ribbon.ListItem.New doesn't appear when list is added via a webpart


I have added a button to a project task list (id = 150).
Everything works fine when I directly use the list. But when I add the list via a webpart to the site page my new button is not available. It's exactly the same ribbon as in the list view but my new button is not visible. Any suggestions?

  Title="Ribbon Customization for a Content Type">
    <CommandUIDefinition Location="Ribbon.ListItem.New.Controls._children">

Update Parameter doesn't update if Null


I have a vb.net page that has an optional parameter.   If a user enters data for that field, and clicks save, it saves fine via the stored procedure.  HOWEVER, if the user changes their mind, and wants to erase the data they entered, they go to the text field, and delete the characters, and click save, but no matter what, the stored procedure will not save the fact that they erased the data (it won't set it back to NULL).  If the user enters a space, the stored procedure will save the space, and if they enter different data, it will save the other data.  I can't figure out how to get it back to letting them set it to Null?      I think this is because it's an optional parameter, and the stored proc is used by several forms (Some of those forms do not include this parameter), but this form utilizes that optional paramater. 

Here's my stored procedure...

CREATE PROCEDURE [dbo].[123456]
@hdnMatterID int,
@BillingArrangementID int,
@BillingArrangementDetails varchar(200) = NULL,   -----This is the parameter that can't seem to get set back to null if a user changes their mind and tries to erase the stored data...
@BillingFrequencyID int


UPDATE  t123456
SET BillingArrangementID = @BillingArrang

remote execution of ssis package using wcf doesn't like date parameter


I have a ssis package remotely executed by a C# windows application that runs ok in context of SSIS installed on the desktop; I created a wcf windows service that the C# application executes, creates a copy of the package with the date in the variable, but errors on the first SQL task component that requires the date. The copy executes using the SSIS utility. What is possibly the issue with wcf and the date type in the SSIS package? Here is the error:

OnError,SRVR2BLADEA3,MIC\1347259,Clear CII ImportDate,{AB3CF5BA-C114-40F6-9ECB-4C7620D97829},{8B1C10CB-580F-4BFE-BC7D-0B97C181E307},9/27/2010 3:29:56 PM,9/27/2010 3:29:56 PM,-1073548784,0x,Executing the query "" failed with the following error: "The type initializer for '<Module>' threw an exception.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

Here is the code:

case @"E:\SSIS Packages\CIISCImport.dtsx":

//string dtValue = (prms[iPrms - 1].Split('=').GetValue(1).ToString()) + " 12:00";

vars["User::ImportDate"].Value = DateTim

sql profiler doesn't show mdx report parameter values


Hi All,

Is there any way that I can afterwards see the members selected as parametervalues in an SSRS report. 

Maybe I'm missing something, but to me its looks as if SQL Profiler is capturing the mdx dataset queries exactly as specified in the report definition, but SQL Profiler does not show the parameter values selected by the end-user.

For analysis puposes I need to figure out what parameter values have been selected by my end-users on report-execution.

Any suggestions/workaround for this ?

Kind regards,



Please remember to mark replies as answers or at least vote helpfull if they help and unmark them if they provide no help.

Table-valued parameter with ObjectDataSource


I'm trying to figure out if it's possible to use an ObjectDataSource Update method with a table-valued parameter.  Here's my ODS:

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
        SelectMethod="GetTestData" TypeName="TestProject.BLL.TestBLL"
            <asp:Parameter DefaultValue="65" Name="testId" Type="Int32" />

I bind this to a GridView but I'm not looking to edit row by row.  Instead my GridView has a bunch of TemplateFields with textboxes.  I also have a Button that when pressed, invokes the Update method of the ODS.  So then the "UpdateTestData" function in my TestBLL is called.  This looks like this:

ObjectDataSource doesn't query on postback


I have two methods for an ObjectDataSource:

Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSearch.Click
        SearchWord = txtSearch.Text

that should fire first and then I have this method that I expect to fire after click event above and on every postback:


Protected Sub objWebUploadLog_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles objWebUploadLog.Selecting
        If SearchWord = "" Then
            objWebUploadLog.SelectMethod = "GetWebUploadLogByUserID"
            objWebUploadLog.SelectCountMethod = "GetWebUploadLogCountByUserID"
            Dim param As WebControls.Parameter = New WebControls.Parameter("search", TypeCode.String)
            objWebUploadLog.SelectParameters("search").DefaultValue = SearchWord
            objWebUploadLog.SelectMethod = "GetWebUploadLogByUserIDAndSearch"
            objWebUploadLog.SelectCountMethod = "GetWebUploadLogCountByUserIDAndSearch"
        End If
     End Sub
But selecting event doesn't fire on a postback that is initiated by

How do I remove a parameter value from one paremeter after it is selected in another?


I have two single valued parameters each populated from the same dataset.  After a value is selected in the first parameter I want to remove it as an available value from the second.

So the first parameter list is A,B,C

The users selects B, and then list of values in the second parameter changes from A,B,C to A,C.


how to capture text from text field and pass to input parameter of dataconnection added as rules in


Hi All,

I have a small application on infopath form published to Sharepoint form library.

I have a text field where i enter serial number to search.

And on rules of search button i added rule where i pass input text to input parameter of dataconnection.

This dataconnection is actually a web service which get details of serial number from SQL database

and then on another button "remove record" rule added where if data is there..which result from first button then delete record from form library and database and enter log details to SQL table ..these all steps writtern in try catch of a webservice.

My problem is:

1. when i enter text to search i need to click twice on search button to get data from SQL ..or i have to click on outside of text field (anywhere in form) to get the event changed and then to click to button to search.

2. when i click on "remove record" button i get error message as error in accessing datasource..

but when i check in preview its working fine


pls advise


-- Regards Sandeep

SQL timestamp in GridView and manually added update parameter for stored procedure in C#



I have a SQL table containing a timestamp column.  This table is displayed in ASP using GridView control.

The timestamp column is indicated in the DataKeyNames property of the GridView.

I'm using TemplateFields for all columns and a ItemTemplate HiddenField control connected to the timestamp column using Eval.

<asp:TemplateField ItemStyle-Wrap

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend