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

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

ObjectDataSource doesn't query on postback

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

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

View Complete Post

More Related Resource Links

jquery click event doesn't fire after postback anymore

Hello there,I have a small website where I want to display a confirmation dialog after clicking on a button.When you click the confirmButton the dialog appears. Then you can choose between Yes or No to either continue with the PostBack or to return.Problem: The first time you get into the site all works fine. But after you click Yes to continue with the PostBack, no click event will be triggered anymore.Here is some code.<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <script type="text/javascript"> function loadConfirmDialog() { //Dialog configurieren jQuery('#confirmDialog').dialog({ autoOpen: false, width: 400, modal: true, resizable: false }); //Dialog öffnen jQuery('#confirmButton').bind('click', function () { jQuery('#confirmDialog').dialog('open'); return false; }); //Postback ausführen jQuery('#continueButton').bind('click', function () { jQuery('#confrimDialog').dialog('destroy'); __doPostBack('confirmButton', ''); }); //Postback abbrechen jQuery('#cancel

2005sql server doesn't respond to the query

<!-- [if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves/> <w:TrackFormatting/> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF/> <w:LidThemeOther>EN-US</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>FA</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:SplitPgBreakAndParaMark/> <w:DontVertAlignCellWithSp/> <w:DontBreakConstrainedForcedTables/> <w:DontVertAlignInTxbx/> <w:Word11KerningPairs/> <w:CachedColBalance/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathPr> <m:mathFont m:val="Cambria Math"/> <m:brkBin m:val="before"/> <m:brkBinSub m:val="--"/> <m:smallFrac m:val="off"/> <m:dispDef/> <m:lMargin m:val="0"/> <m:rMargin m:val="0"/&g

Query doesn't complete - pls help

Hi, the following query which has been used many times before, just never seems to complete this time. Other than a table name, nothing has changed. The table being updated has 16 million rows and the 2 views used in the select have 216 and 360 million rows. The query has been running for 18hrs now. It has necessary indexes. my search online, found some results where it says that sometimes with SQL 2005, SP2, some people have had this problem, but did not find anything that would help me. I checked for indexes, ran the DBCC free proccache killed and restarted the query with a different session (out of desperation) nothing made difference. When I checked activity monitor, someitmes, it would display as sleep_task. The CPU and Disk I/O numbers keep changing, but the timestamp for the last batch is the same as when I started the query. Also tried the SQL profiler, but did not find anything useful, as my query did not even show up in that trace. There are actually multiple queries like this, and this is only one of them. The server is a pretty robust one and also there were times, when there was nothing else running on the SQL server and still the query won't complete. Query: with cte as (select distinct p.PID id , p.HouseHoldID, Q.[Living Unit ID] , q.[source code] sc, q.[sequence number] sn from vw_All_HH_Persons p join vw_All_Household_Details h on p.hhde

Jquery.tools tabs doesn't retain tab index on postback

The graphic designer of a project I'm building a web site for chose jquery.tools (http://flowplayer.org/tools/tabs/index.html) for a tabs tool in the site. Unfortunately it seems that the tool doesn't behave properly on a postback in IE7 or IE8 (it does behave properly in FireFox, Chrome and Safari). Does anyone have experience using the jquery.tools with asp.net? and know how to retain the tab index on a postback? I've tried a lot of things and can't get it to work. The code i'm using now is as follows:           $("ul.tabsScenario").tabs("div.panes > div");         var tabIndex = $('#ctl00_ContentPlaceHolder1_EnInDeToekomst1_HiddenFieldTabIndex').val();         $("ul.tabsScenario").tabs('select', tabIndex); where the tab index is stored in a hidden field (HiddenFieldTabIndex). The above code works fine in Firefox, Chrome and Safari, but not in IE7 or IE8. I am using a ScriptManager and UpdatePanels, but in an extremely simple website example I can't even get the jquery.tools tabs tool to work. There are some unanswered posts on the Jquery.Tools forum concerning this topic, but yeah, that doesn't help much. I've already determined that the

Using jQuery .hide() and .show() on panel sets doesn't maintain status through postback. Viewstate

I'm using jQuery against a set of three asp panels.  I set up an 'onChange' function for a dropdown list that dictates which panels to hide and show based on the UI selection.When the page first loads, one of the panels will be shown, the others will be hidden.  Let's say pnlOne is showing because the dropdown has option 1 selected.  This is done on the server with this:pnlOne.Style.Add("display","block");//and all the other panels are set to ".Style.Add("display","none");" based on logic.Then, the user selects a different value in the dropdown.  Let's say they select option number 2.  With javascript and jQuery I do this:$("#<%=pnlOne.ClientID %>").hide();$("#<%=pnlTwo.ClientID %>").hide();$("#<%=pnlThree.ClientID %>").hide();switch($("#<%= ddlOptionNumber.ClientID %> option:selected").text()){case "1":$("#<%= pnlOne.ClientID %>").show();break;case "2": etc.,}The issue is when the page posts back.  I'm running client side validation only at this point.  (Even if I add client side in the future I will still run client side as well to avoid security issues.)  When the validation functions detect an issue and the page returns to be displayed, the original panel (pnlOne)

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

page inside update panel doesn't refresh the session object after postback of any control



I have many controls like dropdown, radiobuttonlist, etc on my page and I put all these controls inside the update panel so that the page doesn't look to be posting back when something is selected. Now the working on the page is very smooth. But the session object isn't getting refreshed even if I postback to the server and as a result even if the users are working on the page they are being sent to the login screen after 20 mins.

Is there anyway where I could put all the controls in update panel and still refresh the session after any postback(dropdown selection)

Any help is greatly appreciated.

Thanks in advance

SQL query gives results, but Visual Studio doesn't



I have problem accessing data from SQL query in ASP.net. I checked the query and it returns two fields, both with data, but when I run the same query in Visual Studio I get the following error: "Invalid attempt to read data when no data is present."

The problem is that data does exist...

This is what SQL query returns when executed on SQL Server Management Studio (I bolded the different header so you can see the difference):

url idClanak
Upload/Default2.png 8
Upload/Default3.png 8
Upload/Catrinel Menghia 7.jpg 8

The following is the ASP.net code (I bolded the piece of the code that apparently has some problems):

    private void Upisivanje(int idClanak, string naslov, string datumString, string kategorija, string autor, string slika, string opisSlike, string sadrzaj)
        string facebook = "<a href='http://www.facebook.com/sharer.php?u=" + Request.RawUrl + "&t=" + naslov + "'><img src='Images/Facebook.png'/></a>";
        string twitter = "<a href='http://twitter.com/home?status=" + naslov + " na: " + Request.RawUrl + "'><img src='Images/Twitter.png'/></a>

ObjectDataSource doesn't remove previously added Parameter



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)

Linq to XML query doesn't show data with null values...need it to!


I've got a web service that returns xml from a linq query.

If i have fields 'name' and 'title' my linq query will return results that have data in both 'name and 'title' fields.

How can I get linq to return a query when both fields are populated, and when only the name field contains data?

Here's what I've got:

        public XmlDocument GetUsersByDate()
            StringBuilder sb = new StringBuilder();
            XmlWriter writer = XmlWriter.Create(sb);


            var SelectedUsers = (from u in db.Users
                                 select "<UserName>" + u.UserName + "</UserName><x>" + u.Title + "<x>").ToList();


Crawl doesn't work and Query server is not responding; Search works only for old (crawled) contents


We have following three servers with MOSS 2007 STD deployed in SharePoint server farm,


App01- Query Server

App02 - Index Server (We are using this server as dedicated web front end computer for crawling)

SPDBServer - SQL 2005


Search was working fine till 01/05/2008 and it stopped working after this date only for new contents meaning search is still working fine for the old contents which were added before 01/05/2008 but not for new contents added after 01/05/2008.


We have been working to find out reasons why did that happen? We have found following event ids on Query server,


Event ID:10042 - A new query machine, 'App01', has been added to the query rotation based on changes to farm topology.

jQuery $(document).ready() and ASP.NET Ajax asynchronous postback

Many call it the ASP.NET jQuery postback problem, but using the technique below should make it no problem anymore. $(document).ready() isn't called after an asynchronous postback. What this means? You lose the functionality that should be executed within $(document).ready() after an UpdatePanel rendered its contents after an asynchronous postback.

MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.

jQuery live() and ASP.NET Ajax asynchronous postback

The issue is that normally $(document).ready() is called when the DOM is ready to be manipulated. But this doens't happen after an ASP.NET Ajax asynch postback occurs.

This means that the initial jQuery bindings won't be automatically available after the asynchronous postback is over. I underline "automatically" here because my last post describes more possibilities, how this issue can be worked around.

Maintain HTML Radio Button Selection Inside GridView After Postback

Long time ago I wrote an article about getting the value of the selected RadioButtons inside the GridView control. The code did not addresssed the postback issue which means that the selected radio button was cleared after the postback occurs.

How to Encrypt Query String Parameters in ASP.NET

Encrypt Query String Parameters in ASP.NET.u can send secure data one page another page u can also use query string to encrypt

Content Query Web Part missing in SharePoint 2010

If you don't see content query web part listed in the web parts list, this is because you have not enabled "Search Server Web Parts" feature in site collection features. Enable this feature and content query web part will show in the list of web parts.
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