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

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

linqdatasource.where property troubles

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :ASP.Net
hello,Operator '=' incompatible with operand types 'String' and 'Int32'linqdatasource1.where = "myFieldname = " + AlistBox.SelectedValue;AGridView.DatasourceID = linqdatasource1;AGridView.Databind();above was just freeform ad hoc example... not typed in visual studio so ignore issues like case sensitivity. I get this error from code like that.. why? I'm finding my first experience with linq very negative. I realize I don't know what I'm doing yet, but I'm getting very discouraged... I just need to build a pretty simple search page. My aspx markup contains the linqdatasource with everything setup except the 'where' property, which obviously I need to control at runtime based on user input on the search page. I do have a way of making my page work using the linqdatasource's 'selecting' event but I just don't like that, it seems so out of the way for what should be so simple and straight forward. Change where condition, databind, change where condition, databind, change where condition, databind.. why is it not that simple?edit:ldsMain.Where = "JobNID = " + "\"" + lstJobNumbers.SelectedValue + "\"";             GridViewInventory.DataSourceID = "ldsMain";             GridViewInventory.DataBi

View Complete Post

More Related Resource Links

WPF / Silverlight tutorial: Visibility property and binding

Visibility property is a very powerful and yet often overlooked property available in both WPF and Silverlight. It enables you to set Visibility of certain UIElement objects to different states like: Visible, Collapsed and Hidden (not supported by Silverlight). This tutorial shows you how to use it and how to bind to Visibility property

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.

Get pixel format, raw format, property id list and property items image in VB.net - C#.net.

n this simple article you will learn that how we can get pixel format, raw format, property id list and property items image in VB and C#.net.

Get Pixel Format:

Image consists of pixels to get the format of the pixel we have a property named pixel format. This property returns an enumeration of pixel format. This enumeration tells the pixel format.

To demonstrate make a window application. Drag one button and a picture box on form.

Now write the following code on Button click event:

Jscript error: Object does not support property or method


 Hi, i have little knowledge on javascript but i need to use this code get from somewhere for a jquery to work.

I face this "Jscript runtime error: Object does not support property or method" whenever im trying to run this page.

In my experience, im get this error msg 9 out of 10 times i use javascript in my system.

Im using Microsoft Visual web developer 2008, i wonder if this is related to my problem, i not sure there is anything i need to add as reference or update anything.

But anyway, in short, i just couldn't use javascript code when using this development tool because of this sort of error.

Anyway, it happen that last time i tried use the same type of jquery code in another project and it seems to work well without an error.

But now when im try to use it again in this recent project i created, it come out with this error and i have no idea how to solve it even look through google and this forum.

It doesn't really seems like its the code problem itself although im not sure, because any javascript code just couldn't work.

So below is my code that i need to use.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
<script type="text/javascript" src=&quo

linqdatasource parameters question



I'm currently getting to know the linqdatasource control. What would happen if several WHERE parameters are added to the linqdatasource control declaritively in the aspx page but no WHERE clause is defined? 

1. is there any issue with setting up multiple WHERE parameters in the aspx markup for linqdatasource but then deciding which ones actually get used at runtime by setting the actual WHERE clause at run time? Would the unused parameters simply be ignored and cause no issues?

2. when you need to modify WHERE clause or WHERE parameters at runtime do you need to do so in an event handler? such as linqdatasource.selecting?
I see from the above link it is possible, but is that the standard way to handle controlling filtering in code behind for linqdatasource?

2b. if you use an event such as linqdatasource.selecting to add where parameters and/or modify the where clause in code will that also break the builtin sorting and paging support of the linqdatasource with a gridview? 

using the linqDataSource control programmatically (dynamically)



my scenario is this: I want to use the linqDataSource control to bind data to a gridview for it's efficient built-in paging and sorting features *but* I don't want the data to be bound until the user has input various search parameters, so I need to bind the data from a button click event. Also, the search options will be somewhat complex in that there will be several optional search parameters, via various dropdowns and textboxes, so I can't just declaratively/statically setup all the WHERE parameters on the linqDataSource (at least I'm assuming I can't, or that it may result in poor performance if I do and just assign default values like the everything wildcard '%' for the cases the user doesn't use a particular search parameter). Given that brief description, here is an example of what I'm doing, but with only one WHERE parameter for simplicity, the real code will be adding anywhere from 1 to about 12 WHERE parameters depending on how the user sets the search options in the GUI.

the linqDataSource on the aspx page:

<asp:LinqDataSource ID="ldsMain" runat="server" 
        Select="new (field1, field2, field3, etc..)" 

Is it possible to populate property choices from a database?


I'm creating my first server control, and have it working where I can set up an enum and the user can set a property's choices,  based off of that enum.  But I'd like it to pull records from a database and populate the list of choices for the property from a database.  This would allow me to add a new "Host System" to the database, and the other designers wouldn't have to get a new copy of the dll.



Custom Server Control Property not maintaining state


I have created a server control consisting of a TextArea and a div under it.  My goal is to create my own asp:TextArea type control.  the div is for a Character count of the text area and seems to work ok but i added a CharacterCountVisible property to the control that is always returning true.  See Proptery definition below


<Bindable(False), Category("Appearance"), DefaultValue("True"), Localizable(True)> Property CharacterCountVisible() As Boolean
        Return _CountBoxVisible
    End Get
    Set(ByVal value As Boolean)
        _CountBoxVisible = value
    End Set
End Property

Note the _CountBoxVisible variable is define inside the class as :

Dim _CountBoxVisible as Boolean = True

What I am trying to do is give the user/coder the option to show/utilize the char count feature.  Can make it disappear with textarea1.CharacterCountVisible = False but setting it to true will not make it display.


What am i missing





Category attribute of user control property does not work correctly in categories tab.



I have a User Control (ascx) and a property which a want to display in my categories tab in Visual Studio in the category named "Styles".

[Category("Styles"), DefaultValue(""), Description("The value for formating something.")]
public String MyFormatProperty
set { /* the code for set */; }
get { /* the code for get */; }

And here is the problem: Actually I do not need a get, because I only have to set the property (write only property). But when I omit the get, the property is displayed in the "Misc" category in the categories tab in Visual Studio. Only when I code the get as well, then the property is displayed correctly in the "Styles" category in the categories tab in Visual Studio.

Does anybody know why? How can I display the category correctly only with set?

Thanks, S.

Need to know (the value of a) clientside property on the serverside


I need to know on the serverside, if a RadioButton has been disabled (by javascript) on the clientside.


The (serverside) Enabled property is not the same as the (clientside) disabled property. Using MyRadioButton.Attributes("disabled") doesn't do the trick either.


Any clue?

Using Dynamic Property inside Html Helper with Razor fires an error



I have the following with Razor:

@Html.GoogleAjax(View.GoogleAjaxKey, new String[,] { { "jquery", "1.4.2" } })

And the I get a strange error:

  'System.Web.Mvc.HtmlHelper<object>' has no applicable method named 'GoogleAjax' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.

What is strange is that it works fine using:

@Html.GoogleAjax("123", new String[,] { { "jquery", "1.4.2" } })

I tried the following code line:


And the key is displayed just fine so the problem is how I use the value of @View.GoogleAjaxKey into Html.GoogleAjax.

Do I need to change something on my Html Helper? Here it is:

    public static MvcHtmlString GoogleAjax(this HtmlHelper helper, String key, String[,] libraries) {


MVC3: Define Dynamic ViewModel property inside Action Filter



How can I define a Dynamic ViewModel property in MVC 3 inside an action filter?

I am looking to have something like but inside the ActionFilter and not in the controller:

ViewModel.Title = "Home";

Thank You,


What's the problem in my javascript's code to get ClientID Property?



 Hi all.

I wirte a simple java script code to get ClientID of controls on the webform. The code is like:

<script type="text/javascript" language="javascript">

var butt = $find("<%= Button1.ClientID %>");



But when i run it , i have a problem. The probmel is:


Server Error in '/' Application.

The Controls collection cannot be modified because t

Automatically set a property value for a new record in a Dynamic Data application.


I have a SalesOrderItem table, and it has a UnitPrice column in case the salesperson wishes to override the unit price of the Product for that order item.

In an ASP.NET Dynamic Data application, what would be the best way to set that UnitPrice property on a new SalesOrderItem based on the standard UnitPrice for the product? In other words, when the user clicks New on the 'Items' screen for a sales order, the UnitPrice field should already be filled in with the normal unit price for the product.

This was originally asked by myself on StackOverflow at: http://stackoverflow.com/questions/3538234/automatically-set-a-property-value-for-a-new-record-in-a-dynamic-data-application

error in MicrosoftAjax.js: Cannot read property '_notified' of null


I am cross testing my project with multiple browsers: IE7, Firefox and Chrome.

One one page I have a dynamically built table with two DropDownLists and CascadingDropDown extenders. Maybe the only thing special about the drop down lists is, that I add a "onChange" for the second drop down list in each row which shows or hides the list depending on the value populated from the web services.

All of this works perfectly in IE7 and Firefox, but Chrome does not execute the JavaScript in the onChange attribute and the error console says:

Uncaught TypeError: Cannot read property '_notified' of null

User Control and DataSourceID Property


I created a user control (.ascx) that contains a paging-user-control, a repeater and some other controls.
I want to use the property DataSourceID. How should I get the data from the datasource and when?
What is the recommended way?

I did it this way:
- Create a method to get the data by reflection, like:

private void PerformSelect()
	if (!String.IsNullOrEmpty(this.DataSourceID))
		Control control = Page.FindControl(this.DataSourceID);
		if (control == null)
			control = Parent.FindControl(this.DataSourceID);

		MethodInfo method = control.GetType().GetMethod("Select");
		IEnumerable data = (IEnumerable)method.Invoke(control, new object[0]);

		this.DataSource = data;
 - Call this method
In PageLoad when no postback
Changing the current page (paging-user-control)
Changing the current tab (tab-user-control)
Switching Visibility to true

I think that way is not the optimum, is there any better way?
Do you have any suggestions or links?

Thanks for your help, Andreas

User Control as Composite Control Property


I have a composite control (Called Dialog) which has a property "ContentControl"

At design time, I'd like this property to bind to a user control that is on the page.

When I add the items in the designer, the designer loads as expected.

However, when I try to run the web page, I get the following error:

Parser Error Message: Cannot create an object of type 'System.Web.UI.UserControl' from its string representation 'EditTerm1' for the 'ContentControl' property.

Please let me know if there is another way to bind a user control as a property of a composite control.


Designer Code:


	<cc1:Dialog ID="Dialog1" runat="server" Buttons="SaveCancel" 
Title="Edit Term" ContentControl="EditTerm1" />
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