linqdatasource

LinkDataSource can't load DataContext

I am trying to populate a dropdown list control on an web page using VS 2008 and keep getting an error that it can't load the DataContext. My backend is a SQLx server 2005 DB. I create a Link To SQL data context and have 1 table in it. My LinKDataSource is as follows - asp:LinqDataSource ID="LinqDataSource1" runat="server"ContextTy...

LinqDataSource/ListView for child records - only save when the containing record is saved?

I have a single form for editing an event, in which the user can (a) edit the details of the event (title, description, dates, etc.) in a FormView and (b) view and edit a ListView of contacts who are registered for the event. Here's my LinqDataSource, which allows me to add and remove contacts to the event. <asp:linqdatasource runat...

Rebinding GridView using LinqDataSource

I have a gridview that is using a LinqDataSource for it's datasource. I've added a FooterTemplate so users can insert new records. The Add Button has a command name that puts the values in a Dictionary list and then calls the LinqDataSource.Insert() method. This works fine. But the gridview never refreshes automatically with the new ...

LinqDataSource does not work with Microsoft.Reporting.LocalReport

I´m trying to generate a report using a LinqDataSource, placed on a aspx page, and a LocalReport. The code speaks for himself: //Creating report Microsoft.Reporting.WebForms.LocalReport report = new Microsoft.Reporting.WebForms.LocalReport(); report.ReportPath = Request.PhysicalApplicationPath + @"path\To\report...

Passing LinqDataSource through Session: 'DataContext accessed after Dispose.'

I´m in need to pass some results from the database around. Instead of pass a whole dataset, or a constructed sql query, I tried to pass a LinqDataSource configured object. On the source page, I configure the LinqDataSource object properties Where and WhereParameters using the values set by the user on the controls displayed on the page ...

How to modify Bind("MyValue") in asp.net

Hi, I'm having headache with Time values and multiple time zones. I'm storing new DateTime values in UTC time, but I face problem when I try to modify them using LinqDataSource and GridView. I can easily show correct time in <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# TimeManager.ToLocalTime((DateTime)Eval("Order...

Can you prevent LinqDataSource from setting a property?

I've got a Linq 2 SQL object I'm trying to update. Two of the properties on this object are related to each other, and setting one sets the other. So if I do: Foo.Code = BEER; The Foo.CodeID property will automatically be set to 5 (or whatever.) The problem is that LinqDataSource sets Foo.Code, then immediately sets Foo.CodeID... wh...

Can I get the T-SQL query generated from a LinqDataSource?

I´m using the LinqDataSource to populate a grid. But now I need the SQL query that the LinqDataSource generates, to pass around throught methods (no, I can't modify the methods to not need a SQL query). Is there a way to obtain the generated SQL query from a instantiated and configured LinqDataSource? ...

Using Linqdatasource and groupby property

I have a Linqdatasource that groups the records in table:Routing by a field called SubmitTo. My select statement is this - "new (key as SubmitTo, Count() as Count, it as Routings)". Now the SubmitTo field is only a foreign key reference the primary key in table:Department which has a field:DeptName with the full name of the department. H...

Need a good example of LinqDataSource in code, not markup

Anyone have a good example of setting up a LinqDataSource entirely in code? I don't need help writing the LINQ query. I just need help setting up the flow of the code. The reason I want to do it in code is because the complexity of the query I need goes beyond the capabilities of the LinqDataSource wizard. ...

Insert record with EmptyDataTemplate in asp:ListView

I have an EmptyDataTemplate in my asp:ListView which I want to use to insert a new record. I have Inserting working in the InsertItemTemplate... I thought I could copy the InsertItemTemplate into the EmptyDataTemplate, on clicking Insert this gives the error Insert can only be called on an insert item. Ensure only the InsertTemplate h...

ASP.NET Dynamic Data Add Additional Filter Criteria to Page

How should I be adding additional search/filter criteria to a Dynamic Data Web Application? I created a Dynamic Data Web Application using the Northwind database and I am using a custom page for the Employees table (based on the ListDetails.aspx Page Template). I would like to add additional search/filter/where parameters to the Page. ...

LinqDataSource Page 1 queries for all records, pages 2-n queries by page size

I'm passing a LinqDataSource into a Telerik RadGrid. The LinqDataSource is an LLBLGen ORM. Everything is working great - paging, grouping, filtering, etc. all work nicely. I wanted to see how the SQL queries looked. I found these curious results: When I look at page 1, two queries are executed... 1 for the total record count and 1 fo...

Linqdatasource_deleting event doesn't seem to fire

Hi, I am trying to write some code to happen before an actual delete, but cannot get the linqdatasource_deleting event to fire. It only seems to be stepping into the linqdatasource_deleted event. How do I get it to execute the deleting event? ...

Updating LinqDataSource from separate DataContext

I want to update one LinqDataSource with a record retrieved from a different DataContext. The problem is that the DataContext of the LinqDataSource doesn't seem to be made public so I can't get access to it to attach the new object to the DataSource's context. What is the normal way of doing this? Or should I just scrap the LinqDataSou...

How to show headings in GridView with no results

What is the best way to still show column headings on a GridView that doesn't get any records when using LINQDataSource? ...

Why is a child property getting overwritten when a Linq object is being updated?

I'm updating one object, and trying to update any child objects along with it. Basically I'm handling the OnUpdating event of a LinqDataSource. In the DataContext class I have the ObjectUpdate function (where right now I've just got a breakpoint so I can see the values...) In the LinqDataSource.OnUpdating event e.NewObject.Child i...

LinqDataSource query help

Hi All, I know LINQ doesn't have the SQL IN clause but rather uses "contains". Can I use this on a LinqDataSource? I want to write a simple query that is equivelent to this: SELECT * FROM tableA WHERE tableA.requestType NOT IN (5,6,7,8) AND tableA.someBitField IS NULL. Is this possible using the LinqDataSource out of the box? Thanks fo...

Best Practice to renumber items in a list? SQL or C#/VB.NET

I have a database table that has a SortOrder integer column. In the UI for adding and editing table items, I have a drop down list of Integer to let the user select where in the sortorder they would like this item to appear. My question is, say the list, {1,2,3,4,5,"last"}, if the user picks a a number, I want that to be the items SortOr...

The name xxx does not exist in the current context. What am I doing wrong?

var result = from lr in _db.LeaveRequest join th in _db.TotalHourslu on lr.TotalHoursEffect equals th.Minutesselect select new { lr.TotalHoursEffect, th.Minutes, tr.Display }; ERROR: The name '_db' does not exist in the current context The name '_db' does not...