473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Ho do I access sqldatasource in Code Behind?

This is my sqldatasource this is on the page:

Expand|Select|Wrap|Line Numbers
  1. <asp:sqldatasource runat="server"  ID="DS_CheckUserName"  
  2.     ConnectionString="<%$ ConnectionStrings:SQL2005_355184_ConnectionString %>" 
  3.     SelectCommand="SELECT [UserName] FROM [TBL_Poets] WHERE ([UserName] = @UserName)">
  4.     <SelectParameters>
  5.         <asp:FormParameter FormField="UserName" Name="UserName" Type="String" />
  6.     </SelectParameters>
How do I access the selected UserName in in the Code Behind that might look like this...

Expand|Select|Wrap|Line Numbers
  1. if (UserName.Text != DS_CheckUserName.UserName
...where DS_CheckUserName.UserName is the UserName selected in the code above?
Jul 29 '08 #1
3 2901
Frinavale
9,735 Expert Mod 8TB
I'm not sure what control you are using to display the data....
Check out the SqlDataSource Class there are a bunch of tutorials listed on that page....one of which is a Walkthrough on basic data access that I think might help you.

-Frinny
Jul 30 '08 #2
I'm not sure what control you are using to display the data....
Check out the SqlDataSource Class there are a bunch of tutorials listed on that page....one of which is a Walkthrough on basic data access that I think might help you.

-Frinny
That's the point. I don't want to use a control to display the data. I just want to use the data to compare to in my code behind. I don't know how (or if it is possible) to access sqldatasource in my code behind.
Aug 9 '08 #3
kenobewan
4,871 Expert 4TB
That's the point. I don't want to use a control to display the data. I just want to use the data to compare to in my code behind. I don't know how (or if it is possible) to access sqldatasource in my code behind.
There is the alternative if you are not planning to bind the data to a control, you may use a connection, command and data reader in the code behind to obtain the values you want. HTH.
Aug 10 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Swetha | last post by:
Hello I have a DropDownList that I am populating using the following SqlDataSource: <asp:DropDownList ID="parentIDDropDownList" runat="server" DataSourceID="SqlDataSource3"...
2
by: prontoo | last post by:
Hello, I dont know how to get a recordset from sqldatasource with selectcommand and put in standard listbox (not html) when i press the standard button. Thank you
1
by: staeri | last post by:
Hello! I would like to set the SqlDataSource in the code behind file and not to have it in the aspx file. How can I do that? Regards, Staeri
3
by: Dorte | last post by:
Hi, Could someone help me with a couple of links to SqlDatasource documentation on how to use the Gridview and SqlDatasource components in code behind? Basically I'm missing some documentation...
2
by: phil | last post by:
Hi, I want to put a recordset in a gridview but i don't know how to pass the value of the variable in the 'where' statement. The value of the variable is set in the code-behind. i added a tag...
4
by: saturnius | last post by:
Hello, I have to save the data from a gridview as XML file. The code is shown below. Is there no easier way? I would like to access either asp:SqlDataSource (me.SqlDataSource1.something) or...
4
by: Casper | last post by:
Hi, i know how to use datareader in code-behind, e.g. like this: Dim oConnection As OleDbConnection Dim comd As OleDbCommand Dim dtreader As OleDbDataReader oConnection = New...
1
by: Vili | last post by:
Hi all I would like to get some ideas and opinions of my solution for dataconnection on asp.net 2.0 I have created a class which encapsulates the sqldatasource usage. With my class one can...
0
by: ADAC | last post by:
I am very familiar with Visual studio 2003 and trying to get a handle on 2005 I can set up the datasource and make it work fine when I databind it to a control like a gridview or details view....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.