How do I check to see if a value returned from a sql datasource equals a listitem value

I'm trying to see if this listitem equals a value returned in my sql data source, but I get keep getting a error saying  'Item' is not a member of 'System.Web.UI.WebControls.SqlDataSource'.    How do I check if the employeeID returned is equal to the li.value?

For Each li As ListItem In BillingEmployeeID.Items

If li.Value = getEmployeewithMostOpenClient.Item("employeeID") Then
xxxxxxx
End If

Next


Never make important decisions on a Monday!
0
funluckykitty
11/14/2008 6:58:49 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

3 Replies
1052 Views

Similar Articles

[PageSpeed] 26

Try Items.FindByValue() or Items.FindByText() method. Something like this...

string szValueFromDatasource = "two";

ListItem lst;
lst = ListBox1.Items.FindByValue(szValueFromDatasource);

if(lst != null)

{

Response.Write("Item exist");

}

else

{

Response.Write("Item does not exist");

}

0
FYI
11/14/2008 7:58:49 PM

hmmm.. I don't quite understand.  In the past, in the code behind, as part of writing out the whole sql, I was able to set a sessionvalue by doing this (see below).  Is it possible to do this, but with a sqldatasource instead of writing out all the sql?   

 

Session("EmployeeID") = reader2.Item("EmployeeID")


Never make important decisions on a Monday!
0
funluckykitty
11/14/2008 9:25:38 PM

funluckykitty:

hmmm.. I don't quite understand.  In the past, in the code behind, as part of writing out the whole sql, I was able to set a sessionvalue by doing this (see below).  Is it possible to do this, but with a sqldatasource instead of writing out all the sql?   

Hi funluckykitty,

I would like to explain what FYI said before. Let's there is a ListBox named ListBox1 which contains three items, "one", "two" and "three". So, if we need to determine if item "two" is in the ListBox, we can use this kind of codes: 

Dim li As ListItem
li = ListBox1.Items.FindByText("two")
If li Is Nothing Then
    Response.Write("Item exist")
Else
    Response.Write("Item does not exist")
End If

The problem here in your condition is we don't know what getEmployeewithMostOpenClient.Item("employeeID") is. Is it a customized method by yourself? If you can tell more details about this what may be a class, it will easier to find the solution.

Best Regards,
Shengqing Yang


Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread : )
0
Shengqing
11/18/2008 7:38:46 AM
Reply:

Similar Artilces:

Query for substring to get some particular value in a string (Get querystring value by sql )
I have a column name URL in Table1 with data like  <a href="/Folder1/view_media_news.cfm?news_media_i=1">August 2002 Factsheet</a>            <a href="/Folder1/view_media_news.cfm?news_media_i=149">March 2002 Newsletter </a>  i need to grab the news_media_i value by sql query  Please any one can help me to get that particular value from string using substring or any other suggestion Thank you in advance SurendraIf this helps mark it as answer surendra_kla:i nee...

converting meaningful listitem value to sql value
Hi, I hope someone can help me with the below problem I have a dropdownlist that is used to narrow down the results of a gridviewIn the dropdownlist I have specified a couple of a listitem values; <asp:dropdownlist id="ptsearch" runat="server" autopostback="true"><asp:listitem>James</asp:listitem><asp:listitem>Michael</asp:listitem></asp:dropdownlist> In the sql connection part of the code behind I have set the dropdownlist selected value to be passed to a sql stored procedure variable called @user;command.Parameters.Add(&q...

Checking to see if values are in a table or not -- if not then inserting the values.
I'm trying to checking my production table table_a against a working table table_b (which i'm downlading data to)Here are the collumns i have in table_a and table_bDescription | FundID (this is not my PK) | Money I'm running an update if there is already vaule in the money collumn.  I check to see if table_a matches table_b...if not i update table a with table b's value where FundID match up.What i'm having trouble on is if there is no record in table_a but there is a record in table_b.  How can I insert that record into table_a?  I would like to do all of this ...

Trying to get this.options[this.selectedIndex].value to return value
In my aspx page, there is some javascript which is not completing its job entirely although it used to...As you can see from line 19 and line 34, the variable is not getting loaded into the url when selecting the database item from the drop down menu. As soon as the item is selected, this.option[selected... should insert the selected item. There are 2 blocks (loadform and loadform2 ) because there are 2 possible ways to get the database name.  If the the button doesn't work that connects to the site and retrieves all the mysql databases, then they just input the db name into a text ...

Need value for DropDownList Listitem to return all values in database
Hi All, Many thanks for all the help thus far.  In short, here's my problem: I am passing controlparameters (from DropDownLists) to my SELECT statement.  Here's the DropDropDownList: <asp:DropDownList id="status_DropDownList" runat="server"><asp:ListItem Value="Open">Open</asp:ListItem><asp:ListItem Value="Closed">Closed</asp:ListItem><asp:ListItem Value= ??? > Get ALL records </asp:ListItem></asp:DropDownList> What value would I assign the Get All records that would return...

Drop down list in Form view returns error when value in bound field (data binding
I get the following error when I click edit to edit the details in the web form:'ddlUserRestrictionType' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: value  I would like it to accept any value which currently exists in the database. Is this easily achievable? With what you've posted, all I can tell is that you are trying to set the SelectedValue of a ddl to a value that does not exist in the list.  It would be helpful if you can post some code and the expected values of this control.~ Timwww.bucketo...

superreview granted: [Bug 451506] The return values of PR_Seek64 and PR_Available64 should be checked in FileImpl::Seek or else file corruption will occur : [Attachment 334836] Check both values.
neil@parkwaycc.co.uk <neil@httl.net> has granted Hiroyuki Ikezoe <poincare@ikezoe.net>'s request for superreview: Bug 451506: The return values of PR_Seek64 and PR_Available64 should be checked in FileImpl::Seek or else file corruption will occur https://bugzilla.mozilla.org/show_bug.cgi?id=451506 Attachment 334836: Check both values. https://bugzilla.mozilla.org/attachment.cgi?id=334836&action=edit ...

superreview requested: [Bug 451506] The return values of PR_Seek64 and PR_Available64 should be checked in FileImpl::Seek or else file corruption will occur : [Attachment 334836] Check both values.
Hiroyuki Ikezoe <poincare@ikezoe.net> has asked neil@parkwaycc.co.uk <neil@httl.net> for superreview: Bug 451506: The return values of PR_Seek64 and PR_Available64 should be checked in FileImpl::Seek or else file corruption will occur https://bugzilla.mozilla.org/show_bug.cgi?id=451506 Attachment 334836: Check both values. https://bugzilla.mozilla.org/attachment.cgi?id=334836&action=edit ...

If Not value or value then....
Hi all,I want to write a simple IF Not then statement in ASP.net 2.0 and I would like some help please.  If Not ntuser = "DOMAIN\ntuser" Or ntuser = "DOMAIN\ntuser2" Then Panel1.Visible = False End If Doesnt work, can you tell me where i'm going wrong please?many thanks.  The first place you're going wrong is in telling us it "doesn't work" without providing any details. JeffPlease: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue. Use Not as stated below. It ...

DbNull.Value doesn't see null values in SQL
How do I get DbNull.Value to see Null values in SQL? Here is my code... ..... Imports System.Data.SqlClient Imports System.Data.SqlTypes ..... Protected Sub PickColor(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles datagrid.ItemDataBound if e.item.itemtype=ListItemType.Item or e.item.itemtype=ListItemType.AlternatingItem Then Dim idate1 as Date = e.Item.Cells(8).Text Dim Today As DateTime = DateTime.Now Dim thedate As DateTime thedate = e.Item.Cells(8).text Dim idate2 As DateTime = thed...

Getting a value from a SQL table displaying a specific page based on that value
May seem to newbie but here goes:I have a login page.  For the login I run a stored procedure with 4 return values, 0 - being valid, 1 - username exists already, 2 - username is incorrect3 - password is incorrectThis all works fine.  But from that I have the default page when the login credentials are correct.  The issue is I need to display a specific default page based on their location id from the member table which I already run a sp against for the login.  I have set up an .ascx page with a datagrid to display the results which works when I run the query for a h...

How to get return value or output value from stored procedure with sqldatasource control?
I created a user registration web page with sqldatasource, some textbox controls or submit button web control, I applied below stored procedure in insert command of sqldatasource control, but how can I get return value from stored procedure after clicking submit button, I want to judge whether data has been saved into database by return value, then give user a message. Who can tell me? thanks much. ALTER PROCEDURE UserInsert ( @Email nvarchar(50), @Password nvarchar(50), @FullName nvarchar(50), @Phone nvarchar(50), @Mobile nvarchar(50), @Address nvarchar(100), ...

HOW DO YOU get return value from SQL Server command
I need a return value from a SQL Server 2005 command "EXECUTE AS USER = 'user' WITH COOKIE INTO @COOKIE". I'm using Powerbuilder 10 - DBMS=OLEDB PROVIDER='SQLOLEDB', IntegratedSecurity='SSPI' Does anyone have a suggestion to steer me in the right direction? TF You'll have to pardon my ignorance, I've never seen this command before. What return value are you expecting? Is it a success/failure code? How are you running the command? Brad tflooder wrote: > I need a return value from a SQL Server 2005 command > "EXEC...

get value from <select> value & display value
hi all, i want these two bold values which are below,  underline value i can get but second bold value i m not avail to get please help.... <select><option value="ma">manoj</option> </select> regard khushak  P.S. if possible then Please with  java script other wise code behind New In .NET World See my post in this thread.  That should take care of you. Peter BrunoneMS MVP, ASP.NETFounder, EasyListBox.comDo the impossible, and go home early....

Web resources about - How do I check to see if a value returned from a sql datasource equals a listitem value - asp.net.getting-started

Datasource - Wikipedia, the free encyclopedia
A DataSource object has properties that can be modified when necessary. For example, if the data source is moved to a different server, the property ...

Inverness Graham Acquires DataSource
Inverness Graham , a lower middle market private equity firm headquartered in suburban Philadelphia, has acquired DataSource , a print supply ...

SmartGlance for iPad for iPad on the iTunes App Store
Read reviews, get customer ratings, see screenshots, and learn more about SmartGlance for iPad on the App Store. Download SmartGlance for iPad ...

Chaitanya Pandit (@chaitanyapandit) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Data source - Wikipedia, the free encyclopedia
... Data source A data source is any of the following types of sources for (mostly) digitized data: a database in the Java software platform, datasource ...

2ndQuadrant - PostgreSQL expertise from specialists with a source code level understanding of RDBMS ...
PostgreSQL expertise from specialists with a source code level understanding of RDBMS PostgreSQL Planets Gabriele’s PlanetPostgreSQL Gianni’s ...

Tagged entries for CLOUD COMPUTING
Alan Williamson's output as a Java Champion, Blog-City Architect, BlueDragon Creator, Author, Speaker and Internet Guru

Private equity deals
... of biometric identity management systems, applications and services. www.crossmatch.com Inverness Graham Investment has acquired DataSource ...

C# C Sharp and Tutorials on C# Friends.com
Learn the c# langauge to build web applications using our online tutorials with live demos. Participate in our forums and learn from others. ...

JavaScript UI Library, Ajax Components & HTML5 Framework - DHTMLX
DHTMLX offers a rich JavaScript library, UI components & HTML5 mobile framework. Build impressive web apps for both desktop and mobile devices. ...

Resources last updated: 12/27/2015 11:37:04 PM