Can't Set LinqDataSource InsertParameters From Code Behind

Mar 31, 2010

I have the following code that seems like it should set my insertParameter but everytime an insert happens it uses the default parameter. Do i need to do anything special to make this work?

Codebehind:

protected void SetInsertParams(object sender, LinqDataSourceInsertEventArgs e)
{
if (lbl_Personnel.Visible)
{
lds_Personnel.InsertParameters["BudgetLineTypeCode"].DefaultValue = "S";
}
else if(lbl_Operating.Visible).........

View 1 Replies


Similar Messages:

DataSource Controls :: LinqDataSource.Insert(values) Versus InsertParameters

May 26, 2010

I use LinqDataSource and need to make insert not from any data-bound controls like formView (just by pressing button on page).

In SqlDataSource I can set InsertParameters like this

<InsertParameters>
<asp:ControlParameter ControlID="ddlPrice" DefaultValue="0" Name="Price"
PropertyName="SelectedValue" Type="Int16" />
<asp:ControlParameter ControlID="ddlDisc" DefaultValue="0" Name="Discount"
PropertyName="SelectedValue" Type="Int16" />
</InsertParameters>

and then just call Insert().

But in LinqDataSource we don't have method Insert() taking no papameters so I need to create collection with values I want to insert.

View 2 Replies

Binding LinqDataSource From Code - Behind To Gridview?

Sep 8, 2010

i have a grdidview control on the .aspx page and i am trying to connect dynamically from code behind and bind the gridview but somehow it throwing me an error... what is wrong with this code?

LinqDataSource LDS_POReport = new LinqDataSource();
LDS_POReport.ContextTypeName = "DataContextDataContext";
LDS_POReport.Selecting += new EventHandler<LinqDataSourceSelectEventArgs>(LinqDataSourcePO_Selecting);
this.gvReport.DataSource = "LDS_POReport";
//this.gvReport.DataBind();

Update:

after i update the code to this.gvReport.DataSource = LDS_POReport;

it works fine but when i try to sort i get this error:

The GridView 'gvReport' fired event Sorting which wasn't handled.

i added this but no effect.

LDS_POReport.AutoPage = true;
LDS_POReport.AutoSort = true;

View 2 Replies

Binding Data From LinqDataSource To Textbox / How To Bind Texbox To One Property From Linqdatasource

Sep 1, 2010

How I can bind texbox to one property from linqdatasource?

I mean something like databinding contols in c# app

View 1 Replies

DataSource Controls :: Get Data From A LinqDataSource From Code Behind?

Nov 18, 2010

If I have a Linqdatasource that isn't connected to a a bound control on my page how do I use the data source to read data in the code behind. ie

var query = (from x in linqdatasource select x)

What I actually want to do is create a data array (myArray) within the code, read all of the data from the linqdatasource (selecting 1 field to form tableDataArray), then compare the two arrays and then write (insert) those into in myArray that are not already in the datasource to the datasource (ie execute an insert back on the datasource).

View 1 Replies

DataSource Controls :: Refresh LinqDataSource From Ascx.vb Code?

Nov 15, 2010

I have LinqDataSource ID="LinqDataSource1" with values - EnableDelete="True", EnableInsert="True" EnableUpdate="True" on my ascx page, furthermore GridView, button a few textboxes, where a fill new values, which I would like save in my database. After click on button I insert new value to the table throught in function stored in ascx.vb page. It is works, but I don't know, how I refresh GridView on ascx page. I tried

LinqDataSource1.DataBind()
GridView1.DataBind()

without any good result, I must refresh page manualy (F5).

View 4 Replies

DataSource Controls :: Retrieve The Data In Linqdatasource In Code Behind?

Jul 30, 2010

How can i retrieve the data in linqdatasource in code behind?i have a dynamic database design with column storing the datatype eg. text, int, date.i need to retrieve the value in order to populate the control and bind it.

View 5 Replies

DataSource Controls :: How To Get A Value From The InsertParameters Collection

Jan 21, 2010

I require to get the "CostPrice" value out of the sqldatasource parameter

so i may use later in my code?

i cant use the Amount value inserted because i have 4 statements in a conditional If Block and i want to get the selected statement.

InvoicesDataSource.InsertParameters("CostPrice").DefaultValue

= Amount

View 3 Replies

Speeding Up LinqDataSource

Mar 4, 2011

Greetings, I have a following question. Suppose where are two tables in the database:

Clients(
id,
name,
address)
Orders(
id,
name,
desc,
datemodified,
client_id)

The second one references the first one, that is each order is assigned to the client. Now suppose I have an .aspx page with a LinqDataSource for Orders table, and a GridView that uses this datasource and displays a table with a following columns:

Order name.
Order desc.
Client name.
Client address.

As far as I understand, the Linq to SQL is designed in such a way, that by default it does not load any associated entities, it only does it when a child property is requested. So, when a page is loaded, the following situation will occur:

First query will retrieve the records from the Orders table. For each row displayed by GridView an additional query will be performed when one of the client properties is requested. Therefore, if we have 100 orders, this means will perform 101 queries instead of one (or even maybe 201, if a query will be performed for each client property)? How to avoid this and make LinqDataSource load all the required fields by a single query? Right now I see the only workaround for this problem - use an SqlDataSource with a join query, that will retrieve all required fields at once.

View 2 Replies

C# - Dynamic Columns With LinqDataSource?

Aug 24, 2010

Im using LinqDataSource like that:

<asp:LinqDataSource ID="LinqDataSource3" runat="server" OnSelecting="LinqDataSource3_OnSelecting">
</asp:LinqDataSource>
And I have ASPxGridView
<dxwgv:ASPxGridView ID="ASPxGridView2" ClientInstanceName="ASPxGridView2Client"
runat="server" AutoGenerateColumns="False"
DataSourceID="LinqDataSource3">
</dxwgv:ASPxGridView>

In this way Im able to add columns dynamically while handling onSelecting event:

protected void LinqDataSource3_OnSelecting(object sender, LinqDataSourceSelectEventArgs e)
{
MyModelDataContext context = new MyModelDataContext();
ASPxGridView grid = ASPxPageControl1.TabPages[3].FindControl("ASPxGridView2") as ASPxGridView;
if(grid.Columns.Count == 0){
GridViewDataTextColumn txtColumn1 = new GridViewDataTextColumn();
GridViewDataTextColumn txtColumn2 = new GridViewDataTextColumn();
txtColumn1.FieldName = "UserId";
txtColumn2.FieldName = "FirstName";
grid.Columns.Add(txtColumn1);
grid.Columns.Add(txtColumn2);
}
e.Result = from u in context.Users select new { UserId = u.UserId, FirstName = u.FirstName };
}

It is all made simply to test cause my idea is to have solution that makes it possible to use inqDataSource as a datasource for de ASPxGridView but join 2 or 3 tables and show results in this grid.

What I want to ask is if its good solution or is there any other better way to present some views made from couple of tables by join?

Second question is that I have Users and Group and I would like to have one table in which I would have two columns Name and Type For groups type would by group and for users type would be user. I dont have such a table in my database Is it possible to create specific class. Create List of objects of that class and fill it using linq query and the use it as linq data source for that grid ?

clas would be:

pseudocode:

Class MyClass {
string Type;
string Name;
}

or is there any other way to create such a table ?

View 1 Replies

DataSource Controls :: LinqDataSource?

Jun 11, 2010

Im trying to build a where clause in c# for a LinqDataSource, but I cant get it to work, heres my code

[Code]....

when I set category to 'Concerts' tyhe where clause is

'Category = Concerts'

this generates an error telling me there is no column called 'Concerts'. I assume I somehow have to enclose the search term in quotes, Ive tried single and double quotes, but nothing works.

View 5 Replies

DataSource Controls :: Using LIKE In A Linqdatasource?

Nov 16, 2010

So I need to take the literal "SELECT....FROM Bay....WHERE Warehouse=1 and ((BAY LIKE '1.0%' or BAY LIKE '2.0%'))I have set up a linqdatasource on my asp page and I want to bind that to a gridview. Here is the start of the HTML:

<asp:LinqDataSource
ID="dsBays"
runat="server"
ContextTypeName="CartonInventory.CartonInventoryDataContext"
EnableUpdate="True"

[code]...

How do I add a parameter so that it includes the LIKE statement?

View 1 Replies

Web Forms :: RadioButtonList And LinqDataSource?

May 5, 2010

ViewState is active and I have a RadioButtonList with DataSourceID to LinqDataSource.If I postback and cause event SelectedIndexChanged, I can read the SelectedValue property, but if the postback is caused by another control, SelectedValue its always empty...Note if I turn ViewState off, works fine, SelectedValue has always a non empty string...

View 3 Replies

Specify Stored Procedure In LinqDataSource?

May 18, 2010

I have a Listview that I want to read the results of a Stored procedure. I have created the DBML object with the table and the stored procedure. When I configure my LinqDataSource on the page I cannot specify the SProc - only the Table. Or do I need to do it in the Listview?

View 1 Replies

C# - Getting Xml Columns From LinqDataSource To Appear In A GridView?

Jul 25, 2010

I have a LinqDataSource and a GridView displaying a table. Columns of type xml don't show up. I'd like them to show up something like they do in Sql Server query outputs, with a link to display the clickable xml, though there may be another approach i'm not considering (maybe a styled display of the xml data, etc.). Two things i'd like to know how to do

First, get the xml converted to a string, and display it in the table. Maybe the first 30 chars.
Finally, style the xml into something useful, like a clickable link to display the full xml, or a sub-table, or a styled string.

So the following works, and displays a nice table, with edit and delete links. But Xml fields are missing. How would you go about adding support for the Xml fields?

[Code]....

View 1 Replies

ADO.NET :: How To Trigger LinqDataSource Programmatically

Mar 16, 2011

how to trigger the Select() method.

Here's the scenario: ASP.NET 3.5 C# app connecting to an MS SQL backend. I created a LINQ to SQL class called test.dbml and dragged a table called tblTest to the design surface. The table has two columns: the primary key is Email and the other column is Name. Then I dropped a LinqDataSource on the page. The LinqDataSource is not connected to a databound control. It will only being used to retrieve the name associated with a supplied email address. In the Page_Load event, I feed the Where clause:

[Code]....

However, I put a breakpoint inside the ldsAdmin_Selected event and it never hits. With an ObjectDataSource, you can use odsAdmin.Select(); to trigger the ObjectDataSource to actually run and return the info. What's the equivalent method of triggering a LinqDataSource?

View 1 Replies

Gridview With Linqdatasource Refreshing View?

Jun 3, 2010

I've a gridview bound to linqdatasource1 and a details bound to linqdatasource2 (for searching).

When I update the data on detailsview, my gridview is not updating. I've tried handling various gridview events and databinding the gridview in code but it doesn't seem to work.

View 1 Replies

C# - LinqDataSource Bound To Dynamic List?

Aug 17, 2010

Im trying to create LinqDataSource that will represent data from dynamically created String list and then use it as a datasource to my GridView.

List<string> users = RetreiveUsers();
LinqDataSource ds = new LinqDataSource();

View 1 Replies

LINQDataSource - Query Multiple Tables?

May 15, 2010

have a database and I've created a DBML Linq-to-SQL file to represent this database. I've created a new aspx page and dropped a linqdatasource and a formview control onto it. When I configure the linqdatasource it gives me the choice only to select * from one table...but I want to pull from multiple tables. e.g. I have tables like simple_person, simple_address, simple_phone, and I want to pull from all of them.

View 1 Replies

Forms Data Controls :: How To Use The Linqdatasource

Apr 15, 2010

I have written the below pages (base of question) to populate my asp.net listview control from an objectdatasource. To allow for easier CRUD commands and to make my application more efficient I want to replace this objectdatasource with a linqdatasource but when I attempt this I receive a binding error which stops my ItemDataBound event firing? I'm basically replacing my objectdatasource with the below linqdatasource...

[Code]....

[Code]....

Am I placing my query within the wrong event? Why does my ItemDataBound event not fire?

PAGES:

[Code]....

[Code]....

View 3 Replies

C# - LINQDATASOURCE Do Not Commit To Database Straight Away?

Nov 6, 2010

I'm using a LinqDataSource with a RadGrid. When I Add a new Grid item and click insert the values are immediately saved to the database.Is there a way where they can be actually not put in the database until I give the command?

View 1 Replies

C# - LinqDataSource - Filtering And Binding To Gridview?

Jul 28, 2010

the problem is not solved the way i wanted but i go ahead give the credit to : ƁukaszW.pl for his time and effort.

i am using gridview control and a linqdatasource and its all working fine and i have added the functionlity of searchingBySubject and i added WhereParameters and than binding my gridview (see the code below) but somehow its not returning any rows and i see i have number of rows based on what i am searching.

protected void btnSearch_Click(object sender, EventArgs e)
{
this.LinqDataSource1.WhereParameters["Subject"].DefaultValue = this.txtSubject.Text;

[ode]....

View 2 Replies

LinqDataSource - Filtering For Null Values?

Aug 19, 2010

I am writing an ASP.Net web application. I have listview, it's datasource is a LinqDataSource. In my database, I have a staff table and I am trying filter for records by their team using a dropdownlist. This works fine, until I select "All" in the dropdownlist. It returns all staff except for the ones where the teamID is null. How can I return the records where teamID is null?

This is my code:

<asp:ListView ID="ListView1" runat="server" DataSourceID="ldsStaff" DataKeyNames="staffID">
<LayoutTemplate>
<table>
<tr>
<th>Name</th>
<th>Team</th>
</tr>
<tr>
<td> </td>
<td><asp:DropDownList ID="ddlTeamFilter" runat="server" DataSourceID="ldsTeams" DataTextField="Team" DataValueField="TeamID" AppendDataBoundItems="true" AutoPostBack="true">

[Code]....

View 1 Replies

Implement Gridview Search Using LinqDataSource

Oct 21, 2010

I have two tables:

Orders
OrderProducts - An order can have 1 to many orderProducts records associated with it.

What I am trying to do (unsuccessfully) is to implement a GridView search using a LinqDataSource wherein the search returns Order results where any of the OrderProduct.Manufacturer columns contain a search query. I was hoping the following would work, however it seems lambda expressions do not work within a Where clause of a LinqDataSource (in VB):

<asp:LinqDataSource ID="dsOrders" runat="server" ContextTypeName="myDataContext" TableName="orders"
Where="orderProducts.Any(Function(op) op.Manufacturer.Contains(@searchTerm))">
<WhereParameters>
<asp:ControlParameter Name="searchTerm" ControlID="txtSearchTerm" DefaultValue="" />
</WhereParameters>
</asp:LinqDataSource>

In C# it would look like:

<asp:LinqDataSource ID="dsOrders" runat="server" ContextTypeName="myDataContext" TableName="orders"
Where="orderProducts.Any(op => op.Manufacturer.Contains(@searchTerm))">
<WhereParameters>
<asp:ControlParameter Name="searchTerm" ControlID="txtSearchTerm" DefaultValue="" />
</WhereParameters>
</asp:LinqDataSource>

The error I am getting is:

No property or field 'op' exists in type 'orderProduct' Any clues as to how to get this working within the LinqDataSource definition, or will I have to handle and set up a custom OnSelecting event?

View 1 Replies

Error Message On Using LinqDataSource In Webforms

Dec 24, 2010

I am binding a GridView with LinqDataSource with AutoDelete functionality enabled. GridView is bound to the Products Table. I have a Products Table and a Category Table with an association on CategoryID. If I try to delete a Category that is referred in the Products Table I cannot do that. Its is totally acceptable, but I want the end user to be notified with some error message. Where to catch this error message?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved