E.Result When Data Source Was Shaped - Linqdatasource Selected Event
Sep 21, 2010
How do I handle using e.Result when my datasource was shaped (select new{})? example aspx markup below:
[Code]....
1) since I shaped, it's an anonymous type right? so what do I cast e.Result to in order to be able to get at the data? 2) I am thinking of using the selected event to handle some conditional page setup based on whether or not any results were actually found from the main query (the one that is used to bind data to a gridView via this linqdatasource control)... so I need to check for count > 0 and if it is, I need to fill a few dropdown controls based on a few new queries
in the selected event it seems even though e.TotalRowCount really is the total row count, when I cast e.Result to a type in order to access the actual data only the current page of data is there? not all.
items only has the 15 records for the current gridView page, not all the records, is this normal? If I need to access all the items in the result do I need to stick with the selecting event instead?
I have a page on which I've thrown a LinqDataSource and a GridView. I've created a DataContext LINQ-to-SQL class called dcResidents.dbml. When I attempt to configure the LinqDataSource to utilize the dcResidents data context - it doesn't appear in the list of options...though under class view (tab in VS) it does appear. I do have several other working datacontexts - why is this one not being recognized by VS?
I am trying to populate the ListView using LinqDataSource data source but the issue I am having is.I need to load the listview on Search button click action.
IN the page_load I kept like this: =========================================== LinqDS.Selecting += new EventHandler<LinqDataSourceSelectEventArgs>(LinqDS_Selecting);
protected void LinqDS_Selecting(object sender, LinqDataSourceSelectEventArgs e) { e.Result = ObjectDS; } ============================================= This works fine but this happens on page load,i want this binding to happen on button click?is there a way to do this?
In my web app, I used LinqDataSource, ListView and DataPager (.NET 3.5 sp1) to implement search feature with paging. I have a button to trigger the search.
But In the first time, the Selecting event of LinqDataSource fire twice and I don't know why (I debugged my code very carefully). I don't use QueryString with DataPager and assign PageSize of DataPager in the first time of page load to prevent the ListView bind again (as in some instructions I found in forum)
How to get the selected item from the listbox in the selected index changed event. I tried: Label1.Text = ListBox1.SelectedItem.Text; It is giving me object set to null reference.
foreach (ListItem item in ListBox1.Items) { if (item.Selected) { //lblResults.Text += item.Text + " "; Label1.Text = item.Text; } }
I have a repeater using a LinqDataSource as a data source. When a query string is entered, I'd like to filter the results, but ONLY when a query string is entered. If there is no query string, the results should not be filtered, all results should be returned.
I'm trying to add a WhereParameter to my LinqDataSource in the Selecting event of the LinqDataSource, but it's not working. Here's my code:
how to bind selected values from two tables to gridview data source, that two tables are from two databases. i created a view by using these two.But error is getting with this query,that is invalid object derivdtbl_1.Expr1. how to fix this?
SELECT dbo.Station_Channel.St_id, dbo.Station_Channel.lid, dbo.Station_Channel.Edit, dbo.Station_Channel.lChannelName, dbo.Station_Channel.lShort, dbo.Station_Channel.lPosition, dbo.Station_Channel.lTransformData, dbo.Station_Channel.lUnits, dbo.Station_Channel.lDecimalPts, dbo.Station_Channel.parameter, dbo.Station_Channel.function_value, derivdtbl_1.Expr1 FROM dbo.Station_Channel CROSS JOIN (SELECT MAX(Fecha) AS Expr1 FROM MeteoStation.dbo.Datos) AS derivdtbl_1 WHERE (dbo.Station_Channel.Edit = 1)
I am displaying a table into a gridview for which I've a SQL query written which uses IF-ELSE condition. In one of the conditions, if the condition stands TRUE then one of the coloms should be eliminated from the table. But I constantly get an error:"A field or property with the name 'IXC_Vendor_Circuit_ID' was not found on the selected data source."
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: A field or property with the name 'ID' was not found on the selected data source.Source Error: An unhandled exception was generated during the execution of the current web request.
I'm attempting to load a GridView dynamically on a button is pressed.The gridview has AutoGenerateColumns="True" (set in skin definition) and has a declarative column definitions as follows:
This all works fine the first time, but as soon as I select a different ddlCampaign item, it throws the"A field or property with the name 'FieldName' was not found on the selected data source" ERRORI kinda understand that it has retained the column mappings from the previous datasource assignment/binding and because the new datasource has different column headings it is throwing the error. What I can't seem to achieve is a clear or reset of defined gridview columns before adding the new columns. I cannot clear all columns because part of the GV defn is declarative.e.g.
I am trying to bind the XML data to a datagrid from an XML file. I don't know why I am getting the message: "A field or property with the name 'User_x0020_Name' was not found on the selected data source."
The "User_x0020_Name" field does exist in the XML file. This is a portion of the XML file.
this is the error: A field or property with the name 'idcode' was not found on the selected data source.and what i am trying to do is this... i don't understand that. i never used DataSet before.
I have created a gridview at runtime. its working fine when i load the grid first time. after when i am selecting next value from ddl to load grid according to that option(selecting from dropdown list and coresponding values showing in grid) showing error that "A field or property with the name 'datafield name' was not found on the selected data source." might be i am getting this error becuze the privious value is not being cleared" can anybody help me with this problem.
I put a sql statement into the textbox,then the result will be bound to the gridview in the page. first time,sql statement is "selecte * from A(B)",and the gridview is ok. second time,sql statement is "selecte * from B(A)",then the gridview will throw a exception the exception is "A field or property with the name 'aa' was not found on the selected data source. i have two tables A and B."
In above SqlDataSource control, I had to pass the SelectParameter (whose value is coming from a ComboBox i.e., whatever comboBox value I selcect from ComboBox, its SelectedValue I had to pass it to the SqlDataSource SelectParameter. I am first time using "SqlDataSource". How to pass the SelectedValue of ComboBox into SlecteParameter of SqlDataSource control ?
I am using two gridviews with one datasourse. I am getting one error
A field or property with the name 'Empid' was not found on the selected data source. Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: A field or property with the name 'Empid' was not found on the selected data source. Source Error:
My code is
<asp:GridViewid="gridview" runat="server" DataSourceID = "SqlDataSource1" PageSize="30" EmptyDataText = "No Records Found" EmptyDataRowStyle-HorizontalAlign ="Center" AllowPaging="true"
I need to generate oval shaped images on ASP.Net pages. Either I need to resize it to oval shape when it's being uploaded or show it as oval shape on the fly.Have a look at cac.mysiteportal.com to get an overview of what I am trying to achieve. I am talking about the 3 oval shaped image on the right hand side.