Search Results

Search found 119 results on 5 pages for 'objectdatasource'.

Page 1/5 | 1 2 3 4 5  | Next Page >

  • Objectdatasource always passes 0 and startIndex and pageSize in asp.net 2.0

    - by 101873438432680351218
    I have a DevXpress ASPXGridview, and I am using ObjectDataSource for custom paging. This is my objectDataSource code on aspx page. <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetItems" EnablePaging="true" TypeName="BLL.Item" StartRowIndexParameterName="startIndex" MaximumRowsParameterName="pageSize" SelectCountMethod="GetTotalItems" > <SelectParameters> <asp:ControlParameter ControlID="hfNumber" Name="number" Type="string" /> <asp:ControlParameter ControlID="hfDesc" Name="description" Type="string" /> </SelectParameters> </asp:ObjectDataSource> When I put breakpoints in BLL code, I see that it always executes with startIndex and pageSize as 0. It does pass the other two selectparameters correctly. Also the SelectCountMethod (GetTotalItems) never gets executed.

    Read the article

  • Problems with Optimistic Concurrency through an ObjectDataSource and a GridView

    - by Bloodsplatter
    Hi I'm having a problem in an ASP .NET 2.0 Application. I have a GridView displaying data from an ObjectDataSource (connected to a BLL class which connects to a TabledAdapter (Typed Dataset using optimistic concurrency). The select (displaying the data) works just fine, however, when I update a row the GridView does pass the old values to the ObjectDataSource. <DataObjectMethod(DataObjectMethodType.Update, True)> _ Public Function UpdateOC(ByVal original_id As Integer, ByVal original_fotonummer As Integer, ByVal original_inhoud As String, ByVal original_postdatum As Date?, ByVal fotonummer As Integer, ByVal inhoud As String, ByVal postdatum As Date?) As Boolean Dim tweets As TwitpicOC.TweetsDataTable = adapterOC.GetTweetById(original_id) If tweets.Rows.Count = 0 Then Return False Dim row As TwitpicOC.TweetsRow = tweets(0) SmijtHetErIn(row, original_fotonummer, original_inhoud, original_postdatum) row.AcceptChanges() SmijtHetErIn(row, fotonummer, inhoud, postdatum) Return adapterOC.Update(row) = 1 End Function Public Sub SmijtHetErIn(ByVal row As TwitpicOC.TweetsRow, ByVal original_fotonummer As Integer, ByVal original_inhoud As String, ByVal original_postdatum As Date?) With row .fotonummer = original_fotonummer If String.IsNullOrEmpty(original_inhoud) Then .SetinhoudNull() Else .inhoud = original_inhoud If Not original_postdatum.HasValue Then .SetpostdatumNull() Else .postdatum = original_postdatum.Value End With End Sub And this is the part of the page: <div id='Overzicht' class='post'> <div class='title'> <h2> <a href='javascript:;'>Tweetsoverzicht</a></h2> <p> Overzicht</p> </div> <div class='entry'> <p> <asp:ObjectDataSource ID="odsGebruiker" runat="server" OldValuesParameterFormatString="" SelectMethod="GetAll" TypeName="TakeHomeWeb.BLL.GebruikersBLL"></asp:ObjectDataSource> <asp:ObjectDataSource ID="odsFoto" runat="server" SelectMethod="GetFotosByGebruiker" TypeName="TakeHomeWeb.BLL.FotosBLL"> <SelectParameters> <asp:ControlParameter ControlID="ddlGebruiker" DefaultValue="0" Name="userid" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters> </asp:ObjectDataSource> <form id="form1" runat="server"> <asp:Label runat="server" AssociatedControlID="ddlGebruiker">Gebruiker:&nbsp;</asp:Label> <asp:DropDownList ID="ddlGebruiker" runat="server" AutoPostBack="True" DataSourceID="odsGebruiker" DataTextField="naam" DataValueField="userid" AppendDataBoundItems="True"> <asp:ListItem Text="Kies een gebruiker" Value="-1" /> </asp:DropDownList> <br /> <asp:Label runat="server" AssociatedControlID="ddlFoto">Foto:&nbsp;</asp:Label> <asp:DropDownList ID="ddlFoto" runat="server" AutoPostBack="True" DataSourceID="odsFoto" DataTextField="url" DataValueField="id" AppendDataBoundItems="True"> <asp:ListItem Value="-1">Kies een foto...</asp:ListItem> </asp:DropDownList> <br /> <div style="float: left"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="odsTweets"> <Columns> <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" /> <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True" SortExpression="id" /> <asp:BoundField DataField="fotonummer" HeaderText="fotonummer" SortExpression="fotonummer" /> <asp:BoundField DataField="inhoud" HeaderText="inhoud" SortExpression="inhoud" /> <asp:BoundField DataField="postdatum" HeaderText="postdatum" SortExpression="postdatum" /> </Columns> </asp:GridView> <asp:ObjectDataSource ID="odsTweets" runat="server" ConflictDetection="CompareAllValues" DeleteMethod="DeleteOC" OldValuesParameterFormatString="original_{0}" SelectMethod="GetTweetsByFotoId" TypeName="TakeHomeWeb.BLL.TweetsOCBLL" UpdateMethod="UpdateOC"> <DeleteParameters> <asp:Parameter Name="original_id" Type="Int32" /> <asp:Parameter Name="original_fotonummer" Type="Int32" /> <asp:Parameter Name="original_inhoud" Type="String" /> <asp:Parameter Name="original_postdatum" Type="DateTime" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="original_id" Type="Int32" /> <asp:Parameter Name="original_fotonummer" Type="Int32" /> <asp:Parameter Name="original_inhoud" Type="String" /> <asp:Parameter Name="original_postdatum" Type="DateTime" /> <asp:Parameter Name="fotonummer" Type="Int32" /> <asp:Parameter Name="inhoud" Type="String" /> <asp:Parameter Name="postdatum" Type="DateTime" /> </UpdateParameters> <SelectParameters> <asp:ControlParameter ControlID="ddlFoto" Name="foto" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters> </asp:ObjectDataSource> </div> </form> </p> </div> </div> I've got a feeling there's huge fail involved or something, but I've been staring at it for hours now and I just can't find it.

    Read the article

  • ObjectDataSource DataObjectTypeName Help. Pass object as parameter

    - by Kettenbach
    I have a partial class (the main class is a LinqToSql generated class) <DataObject(True)> _ Partial Public Class MBI_Contract <DataObjectMethod(DataObjectMethodType.Select, True)> _ Public Shared Function GetCancelableContracts(ByVal dealer As Dealer) As List(Of MBI_Contract) Return Utilities.GetCancelableContractsForDealer(dealer) End Function End Class Here is the method it's calling Public Function GetCancelableContractsForDealer(ByVal dealer As Dealer) As List(Of MBI_Contract) Dim db As TestDataContext = TestDataContext.Create() Return (From mbi As MBI_Contract In db.MBI_Contracts _ Where mbi.MBI_DealerNumber = dealer.DealerNumber _ AndAlso mbi.MBI_PaidFor = True _ AndAlso mbi.MBI_Deleted = False).ToList() End Function I want to use the ObjectDataSource to drive a DropDownList. <asp:ObjectDataSource ID="contractOds" runat="server" TypeName="MBI_Contract" SelectMethod="GetCancelableContracts" DataObjectTypeName="Dealer"> </asp:ObjectDataSource> My aspx page has a Dealer property that is set in a BasePage. My question is how can I pass this property(object) to the ObjectDataSource, so it can be evaluated in my select method. Does anyone know how I can do this? Or am I totally doing this the wrong way? Thanks for any Advice, Cheers, ~ck in San Diego

    Read the article

  • Where does the ObjectDataSource cache data?

    - by Jeremy
    I'm considering using an ObjectDataSource as an intermediate between my page controls and my data access layer & object model. Traditionally I have manually created the object and populate it via a series of findcontrol statements when I need to insert/update data in the database. I'm hoping that I can use the ObjectDataSource to marshal data between my object and my controls, eliminating that manual code, as long as the ObjectDataSource doesn't come with a lot of overhead. I noticed the EnableCaching property, where does the caching occure? is it in view state?

    Read the article

  • Objectdatasource and Gridview : Sorting, paging, filtering

    - by Simon
    Hi there, Im using entity framework 1.0 and trying to feed out a Gridview with a objectdatasource that have access to my facade. The problem is, that it seems to be particulary difficult and haven't seen anything that realy do what i want it to do on the internet. For those who know, a gridview feeded with an objectdatasource, it can't sort automaticaly then you must do it manually. It's not that bad. Where it becomes a nightmare, its when we add paging and filter settings to a gridview's datasource. After many hours searching on the internet, i'm asking you, guys, if anyone knows a link that can explain me how to mix Pagging, Sorting and filtering for a gridview and an objectdatasource! Thanks in advance and sorry for my english.

    Read the article

  • ObjectDataSource Insert and Update methods error

    - by Jack
    I m developing asp.net 3.5 project. When I want to Insert with DetailsView this error occured: Error : ObjectDataSource 'ObjectDataSource2' could not find a non-generic method 'AddCity' that has parameters: CITY_NAME. <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="GetCityByID" UpdateMethod="UpdateCity" InsertMethod="AddCity" TypeName="NOP_CRM.Lib.nop_cities" OldValuesParameterFormatString="original_{0}"> <SelectParameters> <asp:ControlParameter ControlID="GridView1" Name="cityid" PropertyName="SelectedValue" Type="Int32" DefaultValue="1" /> </SelectParameters> <UpdateParameters> <asp:Parameter Name="CITY_NAME" Type="String" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="CITY_NAME" Type="String" /> </InsertParameters> </asp:ObjectDataSource> ... public int AddCity(string cityname) { CITY_NAME = cityname; Insert(); return _CITY_ID; }

    Read the article

  • How to cancel binding ObjectDataSource ?

    - by nCdy
    CheckPara is my OnDataBinding procedure SqlDataSource1 is ObjectDataSource (it's only confusing name) Language is Nemerle, but if you know C# you can read it easy protected virtual CheckPara(_ : object, _ : System.EventArgs) : void { foreach(x is Parameter in SqlDataSource1.SelectParameters) when(x.DefaultValue=="") //Cancel binding } so how can I cancel binding when there is not fully configurated ObjectDataSource ? Or... how can I run binding only when I done with all parameters ?

    Read the article

  • ObjectDataSource.Select with Parameters Time Out

    - by MasterMax1313
    I'm using an ObjectDataSource with a 2008 ReportViewer control and Linq to CSV. The ODS has two parameters (the SQL is spelled out in an XSD file with a table adapter). The Reportviewer takes a very long time to render the output after a button is clicked to generate the report. That's my first problem. Even though it works (most of the time), the processing time worries me, and subsequent requests don't seem to be changing the results shown on the screen. The next issue is that when I go to export the ODS to CSV I'm getting a time out exception on the select method of the ODS (shown below). This works for ODS without parameters, but it seems like now that I've added parameters that it doesn't want to cooperate. I'm fresh out of ideas, any thoughts? <asp:ObjectDataSource ID="obsGetDataAllCustomers" runat="server" SelectMethod="GetDataAllCustomers" TypeName="my.myAdapter.AllCustomers" OldValuesParameterFormatString="original_{0}" > <SelectParameters> <asp:ControlParameter ControlID="StartDate" Name="Start" PropertyName="Text" Type="DateTime" /> <asp:ControlParameter ControlID="EndDate" Name="_End" PropertyName="Text" Type="DateTime" /> </SelectParameters> </asp:ObjectDataSource> After button click to view report - rvAllCustomers.LocalReport.Refresh() Export to CSV (adding the items returned to a list which is then processed by working code) - For Each dr As DataRow In CType(obs.Select(), DataView).Table.Rows l.Add(New FullOrderOutput(dr)) Next

    Read the article

  • Recommendations, Asp.Net ObjectDataSource bind result of webservice call

    - by DerDres
    I need recommendations on how to solve / structure a solution to the following problem. In an asp.net web application i'll have to visualise results returned from a web service call. Im planning to use a repeater server control and bind this with an objectdatasource. The service returns a result of the form: public class SearchResult : IExtensibleDataObject { [DataMember] public Guid SearchId { get; set; } [DataMember] public DateTime Timestamp { get; set; } [DataMember] public int Offset { get; set; } [DataMember] public int TotalResults { get; set; } [DataMember] public IList<ResultDocumentData> Documents { get; set; } It is the collection of Documents that I need to visualise with a repeater which will be associated with an ObjectDataSource. The datasource should work on the type ResultDocumentData; the collection property in the class SearchResult. I think I need to wrap the call to the webservice in a dataaccess layer class, that will have a getDocuments method returning an IList, that the ObjectDataSource can use as its SelectMethod. I think I could make this work, but I would like to know how to do it in an elegant way. Can you give me general recommendations and/or recommendations for the following: WebProject Folderstructure + naming Naming conventions for the name of the service wrapper class Creating the service reference

    Read the article

  • ASP:GridView does not show data with ObjectdataSource

    - by Kashif
    I have been trying to bind a DataGrid with ObjectDataSource having custom paging but no output is display on my usercontrol. Here is the code I am using <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="LeadId" DataSourceID="dsBuyingLead1" AllowPaging="True"> <Columns> <asp:BoundField DataField="Subject" HeaderText="Subject" ReadOnly="True" /> <asp:BoundField DataField="ExpiryDate" HeaderText="ExpiryDate" ReadOnly="True" /> </Columns> </asp:GridView> <asp:ObjectDataSource ID="dsBuyingLead1" runat="server" EnablePaging="True" DataObjectTypeName="Modules.SearchBuyingLeadInfo" OldValuesParameterFormatString="original_{0}" SelectMethod="GetAllBuyingLeads" StartRowIndexParameterName="startRow" MaximumRowsParameterName="maximumRows" SelectCountMethod="GetAllBuyingLeadsCount" TypeName="Modules.SearchController"> <SelectParameters> <asp:QueryStringParameter Name="searchText" QueryStringField="q" Type="String" /> </SelectParameters> </asp:ObjectDataSource> Here are my methods from SearchController class: [DataObjectMethod(DataObjectMethodType.Select)] public static long GetAllBuyingLeadsCount(string searchText) { return DataProvider.Instance().GetAllBuyingLeadsCount(searchText); } [DataObjectMethod(DataObjectMethodType.Select)] public static List<SearchBuyingLeadInfo> GetAllBuyingLeads (string searchText, int startRow, int maximumRows) { List<SearchBuyingLeadInfo> l = CBO.FillCollection<SearchBuyingLeadInfo> ( DataProvider.Instance() .GetAllBuyingLeadswithText(searchText, startRow, maximumRows) ); return l; } Where SearchBuyingLeadInfo is my Data Access Object class I have verified by setting up break points that both GetAllBuyingLeadsCount and GetAllBuyingLeads return non-zero values but unfortunately nothing is displayed on the grid. Only the column headers are displayed. Can anyone tell me what am I missing?

    Read the article

  • DevExpress AspxGridView filter in ObjectDataSource

    - by Constantin Baciu
    Yet another problem with DevExpress AspxGridView :) The context: One Page In the Page, a custom control In the custom Control, a AspxDropDown The AspxDropDown, has a DropDownWindowTemplate In the DropDownItemTemplate, I add a GridView and a paging/sorting/filtering enabled ObjectDataSource When handling the Selecting event of the ObjectDataSource, I should set filter parameters for the datasource. There filter parameters should come from the FilterRow of the AspxGridView (preferably using the AspxGriedView.FilterExpression property). The problem: the AspxGriedView.FilterExpression property is not set to the proper values (set by the user). Did anyone find a good implementation of what I'm trying to do here? Thanks a bunch. :)

    Read the article

  • Cached ObjectDataSource not firing Select Event even Cache Dependecy Removed

    - by John Polvora
    I have the following scenario. A Page with a DetailsView binded to an ObjectDatasource with cache-enabled. The SelectMethod is assigned at Page_Load event, depending on my User Level Logic. After assigned the selectMethod and Parameters for the ODS, if Cache not exists, then ODS will be cached the first time. The next time, the cache will be applied to the ODS and the select event don't need to be fired since the dataresult is cached. The problem is, the ODS Cache works fine, but I have a Refresh button to clear the cache and rebind the DetailsView. Am I doing correctly ? Below is my code. <asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="ObjectDataSource_Summary" EnableModelValidation="True" EnableViewState="False" ForeColor="#333333" GridLines="None"> </asp:DetailsView> <asp:ObjectDataSource ID="ObjectDataSource_Summary" runat="server" SelectMethod="" TypeName="BL.BusinessLogic" EnableCaching="true"> <SelectParameters> <asp:Parameter Name="idCompany" Type="String" /> <SelectParameters> </asp:ObjectDataSource> <asp:ImageButton ID="ImageButton_Refresh" runat="server" OnClick="RefreshClick" ImageUrl="~/img/refresh.png" /> And here is the code behind public partial class Index : Page { protected void Page_Load(object sender, EventArgs e) { ObjectDataSource_Summary.SelectMethod = ""; ObjectDataSource_Summary.SelectParameters[0].DefaultValue = ""; switch (this._loginData.UserLevel) //this is a struct I use for control permissions e pages behaviour { case OperNivel.SysAdmin: case OperNivel.SysOperator: { ObjectDataSource_Summary.SelectMethod = "SystemSummary"; ObjectDataSource_Summary.SelectParameters[0].DefaultValue = "0"; break; } case OperNivel.CompanyAdmin: case OperNivel.CompanyOperator: { ObjectDataSource_Summary.SelectMethod = "CompanySummary"; ObjectDataSource_Summary.SelectParameters[0].DefaultValue = this._loginData.UserLevel.ToString(); break; } default: break; } } protected void Page_LoadComplete(object sender, EventArgs e) { if (Cache[ObjectDataSource_Summary.CacheKeyDependency] == null) { this._loginData.LoginDatetime = DateTime.Now; Session["loginData"] = _loginData; Cache[ObjectDataSource_Summary.CacheKeyDependency] = _loginData; DetailsView1.DataBind(); } } protected void RefreshClick(object sender, ImageClickEventArgs e) { Cache.Remove(ObjectDataSource_Summary.CacheKeyDependency); } } Can anyone help me? The Select() Event of the ObjectDasource is not firing even I Remove the CacheKey Dependency

    Read the article

  • Listview with objectdatasource Delete not working

    - by Radhi
    Hello, i have one Listview in my Usercontrol & 1 objectdatasource binded with the ListView. now in objectdatasource's Deletemethod i have taken businessobject as argument but at runtime i am not getting value in my businessobject's properties... i also tried to use "Bind" instead of "eval" in ItemTemplate. but not getting any value at runtime in my DeleteMethod provided in objectdatasource's Deletecommand... can anybody help to know weather i am mising anything or what? my Listview's ItemTemplate <ItemTemplate> <asp:HiddenField ID="hidUserAchievementInfoId" runat="server" Value='<%# Bind("UserAchievementInfoId") %>' /> <asp:HiddenField ID="hidUserIdField" runat="server" Value='<%# Bind("UserId") %>' /> <tr> <td class="style1"> <asp:Label ID="AwardLabel" runat="server" Text="Award "></asp:Label> </td> <td> <asp:Label ID="lblAward" runat="server" Text='<%# Bind("Awards") %>'></asp:Label> </td> </tr> <tr> <td class="style1"> <asp:Label ID="FieldofAwardLabel" runat="server" Text="Field of Award "></asp:Label> </td> <td> <asp:Label ID="lblFieldofAward" runat="server" Text='<%# Bind("FieldofAward") %>'></asp:Label> </td> </tr> <tr> <td class="style1"> <asp:Label ID="TournamentLabel" runat="server" Text="Tournament "></asp:Label> </td> <td> <asp:Label ID="lblTournament" runat="server" Text='<%# Bind("Tournament") %>'></asp:Label> </td> </tr> <tr> <td class="style1"> <asp:Label ID="AwardYearLabel" runat="server" Text="Award Year "></asp:Label> </td> <td> <asp:Label ID="AwardYear" runat="server" Text='<%# Bind("AwardYear") %>'></asp:Label> </td> </tr> <tr> <td class="style1"> <asp:Label ID="AwardDescriptionLabel" runat="server" Text="Description "></asp:Label> </td> <td> <asp:Label ID="lblAwardDescription" runat="server" Text='<%# Bind("AwardDescription") %>'></asp:Label> </td> </tr> <tr> <td class="style1"> <asp:LinkButton ID="EditButton" runat="server" CommandName="Edit" Text="Edit"></asp:LinkButton> </td> <td> <asp:LinkButton ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete"></asp:LinkButton> </td> </tr> </ItemTemplate> Delete Method used in objectdata source's Deletecommand public void DeleteUserAchievementInfo(UserAchivementInfoBO BOInstance) { try { Int64 UserAchievementInfoId=BOInstance.UserAchievementInfoId objUserBasicInfoServiceClient.DeleteUserAchievementInfo(UserAchievementInfoId); } catch (Exception ex) { HandleException.LogError(ex); } }

    Read the article

  • Asp.net's ObjectDataSource data bind event

    - by DJPB
    Hi there I'm Working on an Asp.net/C# application. I want to bind a list of objects to a grid view. I've been looking a while to the ObjectDataSource control and it loads data to my datagrid as soon as my page loads. Can I change this behaviour? For example, how can I set DataBinding only when a button on my page gets clicked? tks

    Read the article

  • ASP.NET ObjectDataSource Sorting Twice

    - by user204588
    Hello, I'm working with some existing code uses an objectDataSource and that calls a sort method inside a DLL that I don't have access to. I'm trying to add a custom field to sort and I basically want to re-sort after the initial sort. I don't know if this can be done but before the GridView is displayed, I need to intercept the code and sort the way I want to sort. Any ideas? I'm lost.

    Read the article

  • ASP.NET 2.0: Specifying an instance of an object for an ObjectDataSource

    - by Austin Salonen
    I'm using an ObjectDataSource to bind data to a GridView; it works fine except that it always creates a new object to use as a data source. I can do all the setup just fine but I cannot use an instance of an existing object to specify as the "data source" for it. Is it possible to do this? If so, how? If it's not possible, why? EDIT: Here's the gist of what's going on (object types changed): On the first page you are editting the attributes for a dog. One of the attributes is "has puppies" and if it's true, the next page you specify the names of those puppies. What's happening in my case is that those puppies are not getting linked to the original dog but to a "new" dog. (The implication that my problem is a "female dog" was coincidental. ;-) )

    Read the article

  • ObjectDataSource cannot find type when deployed to SharePoint

    - by Sean
    I'm receiving the following error when deploying a feature containing ASP.NET pages to our development SharePoint servers: System.InvalidOperationException: The type specified in the TypeName property of ObjectDataSource 'odsYears' could not be found. Our .dll is being deployed to the GAC and our pages are being deployed to the the respective Features directory in the 12 hive. We are not receiving this error on our Sandbox SharePoint server. I disassembled the .dll to be sure the class was being deployed and everything looked ok. Does anyone have any ideas on why this would not work on one of our SharePoint environments? Thanks.

    Read the article

  • How To Use ObjectDataSource With Complex Objects and FormView Control

    - by obautista
    I have a complex object. For example a SCHOOL object that contains a collection of PERSON object. How can I use the ObjectDataSource control with a FormView and flatten the complex object? An example display would be to display the school name and comma separate the students on the page. Is this possible? I.E. public string Id { get { return m_id; } set { m_id = value; } } public string SchoolName { get { return m_schoolName; } set { m_schoolName = value; } } public List(Person Students { get { return m_students; } set { m_cast = students; } }

    Read the article

  • Problem: Sorting for GridView/ObjectDataSource changes depending on page

    - by user148298
    I have a GridView tied to an ObjectDataSource using paging. The paging works fine, except that the sort order changes depending on which page of the results is being viewed. This causes items to reappear on subsequent pages among other issues. I traced the problem to my DAL, which reads a page at a time and then sorts it. Obviously the sorting is going to change as the result set size changes. Is there an improvement to this algorithm. I would like to use a datareader if possible: [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select)] public static WordsCollection LoadForCriteria(string sqlCriteria, int maximumRows, int startRowIndex, string sortExpression) { //DEFAULT SORT EXPRESSION if (string.IsNullOrEmpty(sortExpression)) sortExpression = "OrderBy"; //CREATE THE DYNAMIC SQL TO LOAD OBJECT StringBuilder selectQuery = new StringBuilder(); selectQuery.Append("SELECT"); if (maximumRows > 0) selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString()); selectQuery.Append(" " + Words.GetColumnNames(string.Empty)); selectQuery.Append(" FROM sw_Words"); string whereClause = string.IsNullOrEmpty(sqlCriteria) ? string.Empty : " WHERE " + sqlCriteria; selectQuery.Append(whereClause); selectQuery.Append(" ORDER BY " + sortExpression); Database database = Token.Instance.Database; DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString()); //EXECUTE THE COMMAND WordsCollection results = new WordsCollection(); int thisIndex = 0; int rowCount = 0; using (IDataReader dr = database.ExecuteReader(selectCommand)) { while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows))) { if (thisIndex >= startRowIndex) { Words varWords = new Words(); Words.LoadDataReader(varWords, dr); results.Add(varWords); rowCount++; } thisIndex++; } dr.Close(); } return results; }

    Read the article

  • Problem wth paging ObjectDataSource

    - by funky
    asp page code: <asp:ObjectDataSource runat="server" ID="odsResults" OnSelecting="odsResults_Selecting" /> <tr><td> <wssawc:SPGridViewPager ID="sgvpPagerTop" runat="server" GridViewId="sgvConversionResults" /> </td></tr> <tr> <td colspan="2" class="ms-vb"> <wssawc:SPGridView runat="server" ID="sgvConversionResults" AutoGenerateColumns="false" RowStyle-CssClass="" AlternatingRowStyle-CssClass="ms-alternating" /> </td> </tr> Class code: public partial class Convert : System.Web.UI.Page { ... private DataTable resultDataSource = new DataTable(); ... protected void Page_Init(object sender, EventArgs e) { ... resultDataSource.Columns.Add("Column1"); resultDataSource.Columns.Add("Column2"); resultDataSource.Columns.Add("Column3"); resultDataSource.Columns.Add("Column4"); ... odsResults.TypeName = GetType().AssemblyQualifiedName; odsResults.SelectMethod = "SelectData"; odsResults.SelectCountMethod = "GetRecordCount"; odsResults.EnablePaging = true; sgvConversionResults.DataSourceID = odsResults.ID; ConversionResultsCreateColumns(); sgvConversionResults.AllowPaging = true; ... } protected void btnBTN_Click(object sender, EventArgs e) { // add rows into resultDataSource } public DataTable SelectData(DataTable ds,int startRowIndex,int maximumRows) { DataTable dt = new DataTable(); dt.Columns.Add("Column1"); dt.Columns.Add("Column2"); dt.Columns.Add("Column3"); dt.Columns.Add("Column4"); for (int i =startRowIndex; i<startRowIndex+10 ;i++) { if (i<ds.Rows.Count) { dt.Rows.Add(ds.Rows[i][0].ToString(), ds.Rows[i][1].ToString(), ds.Rows[i][2].ToString(), ds.Rows[i][3].ToString()); } } return dt; } public int GetRecordCount(DataTable ds) { return ds.Rows.Count; } protected void odsResults_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { e.InputParameters["ds"] = resultDataSource; } } On click BTN button resultDataSource receive some rows. Page reload and we can see result in sgvConversionResults. First 10 rows. But after click next page in pager we have message "There are no items to show in this view". When I try debug I find that after postBack page (on click next page) input params "ds" is blank, ds.Rows.Count = 0 and etc... As though resultDataSource became empty(( What do I do not correctly?. Sorry my English.

    Read the article

  • GridView not DataBinding Automatically after ObjectDataSource Select Method

    - by John Polvora
    I've created a objectadasource that returns a datatable, the gridview is binded to this datasource. the ODS have parameters assigned on the Page_Load event, and the ODS returns the data ok and the gridview shows it fine. the problem is i have a textbox with a filter. first I created a filterexpression in gridview, using the contents of the textbox, worked fine for me. but now I've enabled the paging in gridview. then the filterexpression is not useful now, since the ODS returns only the rows of the pagesize of gridview. I did a new ODS method that select data from parameters page and pagesize according to GridView, and it's OK. now my filter textbox passes his text property to a parameter of the ods select method, then the ods gets the data based on my filter and shows it in the grid. on the Page_Load: ObjectDataSource_Lista.SelectParameters["search"].DefaultValue = filter; ObjectDataSource_Lista.SelectParameters["id"].DefaultValue = ID.ToString(); but when I change the value of the filter, the grid doesn't refresh. on debugging. I see that the ODS Select Method is refreshed ok, but the GridView don't. So I need to call mannually the Databind() method of the grid, to refresh data. the problem is, I have a commandbutton on the grid, and if I manually databind(), the command button stops functioning, generating Page ValidateRequest errors. My question is: how to databind() the grid automatically after the datasource refreshed? ps: on the ODS Selected event, causes a infinite loop and the debug webserver crashes. Temporary solution: Created a Variable private bool wasdatabound; on the event GridView_Databound, set wasdatabound = true; on the Page_PreRenderComplete, if ((GridView1.Visible) && (!databounded)) GridView1.DataBind();

    Read the article

  • How do I get the inserted id (or object) after an insert with the FormView/ObjectDataSource controls

    - by drs9222
    I have a series of classes that loosely fit the following pattern: public class CustomerInfo { public int Id {get; set;} public string Name {get; set;} } public class CustomerTable { public bool Insert(CustomerInfo info) { /*...*/ } public bool Update(CustomerInfo info) { /*...*/ } public CustomerInfo Get(int id) { /*...*/ } /*...*/ } After a successful insert the Insert method will set the Id property of the CustomerInfo object that was passed in. I've used these classes in several places and would prefer to altering them. Now I'm experimenting with writing an ASP.NET page for inserting and updating the records. I'm currently using the ObjectDataSource and FormView controls: <asp:ObjectDataSource TypeName="CustomerTable" DataObjectTypeName="CustomerInfo" InsertMethod="Insert" UpdateMethod="Update" SelectMethod="Get" /> I can successfully Insert and Update records. I would like to switch the FormView's mode from Insert to Edit after a successful insert. My first attempt was to switch the mode in the ItemInserted event. This of course did not work. I was using a QueryStringParameter for the id which of course wan't set when inserting. So, I switched to manually populating the InputParameters during the ObjectDataSource's Selecting event. The problem with this is I need to know the id of the newly inserted record which I can't find a good way to get. I understand that I can access the Insert method's return value, and out parameters in the ItemInserted event of course my method doesn't return the id using any of these methods. I can't find anyway to access the id or the CustomerInfo object that was inserted after the insert completes. The best I've been able to do is to save the CustomerInfo object in the ObjectDataSource's Inserting event. This feels like an odd way to do this. I figure that there must be a better way to do this and I'll kick myself when I see it. Any ideas?

    Read the article

  • ANN: ObjectDataSource and siaqodb -object database for .NET

    Siaqodb -object database for .NET, Mono and Silverlight version 1.1 (just released) fully support now ASP.NET 4.0 and by ObjectDataSource and ASP.NET Dynamic Data, building data-driven apps are faster then ever:http://siaqodb.com/?p=236...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

1 2 3 4 5  | Next Page >