How to Access SqlDataSource Fields from Code?

I have <asp:SqlDataSource> in aspx page that is being used by an updateable GridView.  However, there are a couple fields in the dataset that contain filenames that I want to access directly in code and place them into some image tags on the page. 

This line should give me access to the dataset but how to I access the fields?

Dim myDataSource As DataView = DirectCast(SqlDataSourceGridView.[Select](DataSourceSelectArguments.Empty), DataView)

When the SqlDataSource is a DataReader I would access it with the code below but since this SqlDataSource is a DataSet I can't access it with this code.

If myDataSource.Read Then
   If Convert.IsDBNull(myDataSource("CusAgentPhoto")) Then
      ImageAgent.ImageUrl = "/photos/nophoto.gif"
      ImageAgent.ImageUrl = AgentImagePath & myDataSource("CusAgentPhoto").ToString
   End If
   If Convert.IsDBNull(myDataSource("CusCompanyLogo")) Then
      ImageCompany.ImageUrl = "/photos/nophoto.gif"
       ImageCompany.ImageUrl = OfficeImagePath & myDataSource("CusCompanyLogo").ToString
   End If
End If

What would be the correct way to get at the DataSet fields that contain the filenames?

-- "Mark As Answer" If my reply helped you --
8/19/2007 3:20:35 AM 29906 articles. 0 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 44

Programmatically accessing values from datasource controls: 

Also, How to conditionally show an image: 

Regards Mike
My site
8/19/2007 9:04:45 AM

That was the info I needed. Excellent reference!

-- "Mark As Answer" If my reply helped you --
8/20/2007 2:48:55 AM

Similar Artilces:

.NET Add Command
I added two Parameter Fields to my Report in the Field Explorer. I also can create a SQL Command using the Add Command option in the Database Expert window. However, I would like to have parameters in my Command Query... when I try to add parameters to my command query i get the error "Failed to open a rowset.  Details: 07001:[IBM][CLI Driver] CLI0100E Wrong number of parameters. SQLSTATE=07001" my query is: SELECT TL.PICK_UP_PUNIT,SUM(Case when Master_Order=0 then 1 ELSE 0 END) + COUNT(DISTINCT(MASTER_ORDER)) - (CASE when SUM(CASE when MASTER_ORDER=0 THEN 1 ELSE 0 END)...

Access to a field from my Access DataSource in my DetailsView
I am creating an Audit Trail of changes made to my table using a DetailsView RowUpadated event. This field,  CustomerName, in the table is not being updated so I can not grab the data from my  DictionaryEntry  old or new values statements as I am doing for my audit trail. However, it is in my select statement for the DetailsView from my AccessDataSource. I can’t seem to find a reference where I can get the value of a field from my AccessDataSource. How can I reference it ?  Thx.           <asp:DetailsView ID="DetailsView1" ...

VB.NET Codebehind Code to Update SQL Server 2005 Using SQLDataSource Control?
Hi, I am a newbie in using ASP.NET 2.0 and ADO.NET.  I wrote a hangman game and want to record statistics at the end of each game.  I will create and update records in the database for each authenticated user as well as a record for the Anonymous, unauthenticated user.  After a win or loss has occurred, I want to programmatically use the SQLDataSource control to increment the statistics counters for the appropriate record in the database (note I don't want to show anything or get user input for this function). I need a VB.NET codebehind example that will show me how I sho...

code for Custom paging without using sqldatasource control and sql datasource control for gridview...........
 code for Custom paging without using sqldatasource control and sql datasource control for gridview...........i need code for how to show all pagenumbers in gridview with custom paging in gridview..............It is very urgent................................. T.Ashok Kumar  suppose that we have a table like thisCountryId  identity intCountryTitle    nvarchar(50)you can use this sql command for paging the dataUSE [CyberOffice]GO/****** Object:  StoredProcedure [dbo].[CountryGetListPaged]    Script Date: 09/17/2008 14:01:06 ******/SET A...

can someone translate this code from c# to
what's this in ? string str = ((TextBox)this.LoginView1.FindControl("Login1$UserName")).Text; I'm using the CreateUserWizard and in addition to adding a record to  aspnet_membership table I want to add a record to my customer details table. In this record I want to include the UserName and Email fields from aspnet_membership table. I found the above code,any suggestions as to how I can access these fields for insertion to my customer details table appriciated. Code snippets appriciated Thanks Daviddavid"paddling upstream searching for the s...

Accessing SQL datasource selected values in code behind when they're pulled from formview, listview, datagrid, etc..
Hello, In my usage of 2.0 so far I've been having a consistent lack of technique at one particular concept: In my code behind with vb, getting at the values pulled by my sql datasource that are used in my formviews, listviews, etc... What are some of the general techniques to accomplish this? What are the easiest ways? If I try to assign output parameters in my query I get errors because sql doesn't want them being used for the data consuming controls as well as assigning parameters. Lately I've been making the textboxes that are populated by the f...

.Net Framework Code Access Security
I built a c# .Net 2.0 based user control that I run as an ActiveX control in IE7.  It works fine except for code access security issues ("Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=, ......' failed).  To get around the code access security issues, I created a code group within the Machine All_Code group with the Publisher membership conditions based on a valid certificate (which my assembly has) and granted that code group the "Everything" permission set.  Even though my code group is m...

How to call or retrieve fields from sql and display in table without using, I'm using a dynamic link library....Is the coding different?
Help me! I'm doing my school project on Software Change Management Tool, CR Tracker. I want to display table in the webform, and the table data is retrieve form the sql server. So how do I call the sql so as to display the data in a table? hy..What does that dll contain ?Does it already contains relevant code to connect to a database ? Have a look hereThanksDinuj Nath The easy way to do this is with the use of a data bound grid. The Grid can be customised to look and feel you like. You will need to add a data adapter to your page and a grid. When you setup the data adapter you will nee...

Sql Server Script File(.sql) Execution by Code
I have a problem. I m working on "light weight sql server"  project.   and i want to execute .sql file through code with the help of sqldmo library and sqlns namespace. but i donot know any method to directly execute the .sql file. i am successfully making the full script of select database of sql server.   please help me.... thanks.... Hi, You can use SQL-DMO object in your .net projects by referencing Sqldmo.dll  file which is in  C:\Program Files\Microsoft SQL Server\80\Tools\Binn  folder is default installation parameters are used. I...

Howto: Convert sample SQL dB code to Access dB code?
Hello, In reference to the book: ASP.NET Web Matrix Starter Kit (ISBN: 0-7356-1856-9) Chapter 14 – Creating a Web-Based Calendar. The sample code works great when using an SQL server dB. However Web Matrix allows us to use an Access dB as well. My question is how do I convert the code found on page 275 to work with an Access dB? I have got the rest of the sample code in this chapter to work using Access, but I am not familiar with the proper way to convert this code: Sub DisplayAppointments(dateToDisplay As DateTime) labelSelectedDate.Text = dateToDisplay...

.net code for sql
how to use .net code from sql function. i have sql function - select * from funcname('delta','1/1/2007,'1/1/2008')  but i want to .net code for this function. how do i get it? can anybody guide me i don't know about .net. Thanks for ue help.        Take a look at this article: this provides some insight.- Jesse Jesse WilliamsPlease mark 'Answered' if my post was able to assist you. This may help: Regards,...

Problem importing data from an Access memo field into a SQL Server ntext field.
I'm using DTS to import data from an Access memo field into a SQL Server ntext field.  DTS is only importing the first 255 characters of the memo field and truncating the rest.I'd appreciate any insights into what may be causing this problem, and what I can do about it.Thanks in advance for any help! 255 is the default change the settings to accept more than 255, Access memo must be either image to store the file in Word or Text both can grow to 2gigs because Varchar 8000, Char 8000, NVarchar 4000 and NChar 4000 maybe too small for Access memo column.  Hope this helps.Kind regard...

Passing integer array from VB.NET to Access VBA Code (Access 2003 Interop)
Hello, I'm working on a small project to take a current Access database and move it online. I'm using Access automation using Interop (even though its not recommended, but the service wont be used very often). I have the majority of the code working great, except on one VBA function where I pass it an array of integers. Below is a blurp of the code: VBA function: --------------------------------------------------------------------------------------------------------- Public Sub OutputScheduler0708(ProgramId() As Integer, ProgramTypeID() As Integer, ProgramCnt() As Integer, XLSOut...

Translate code to code
Hi I can usually do the translation myself, but this time I am a bit stumped  Let us consider to rewrite Urls (more than 16000 links) using a table. Save original url and rewritten url in a table. Now add a class file in App_Code folder. class UrlRewriteModule : IHttpModule{    public void Dispose()    {        // Nothing to dispose    }    public void Init(HttpApplication context)    {        context.BeginRequest += new EventHandler(context...

Web resources about - How to Access SqlDataSource Fields from Code? -

Top Ranked Articles
Top Ranked Articles - Free source code and tutorials for Software developers and Architects.; Updated: 23 Feb 2013

Using The LINQDataSource
-*+There is a new datasource control available in Visual Studio that works in much the same way as the SQLDataSource and the ObjectDataSource. ...

Gabriel Mongeon
Archive - Gabriel Mongeon

M ore d otnet .NET Interview Questions, ASP.NET, C#, VB.NET, XML, SQL Check Out √ .NET NOTES OOPS in .NET .NET ...

Architectural Overview of the Windows Presentation Foundation Beta 1 Release
Introduction Windows Presentation Foundation Beta 1 Windows Integration New Features WinFX SDK Exploring the New Features Introducing "Express" ...

About Mikesdotnetting
I started this site as somewhere to store answers to bits and pieces that I see asked frequently in the forums at . Rather than type ...

Using MiniProfiler with SqlDataSource ASP.NET WebForms Control
public class ProfiledSqlDataSource : SqlDataSource{ protected override DbProviderFactory GetDbProviderFactory() { // get the "base" DbProviderFactory ...

ASP.NET Pivot Table - RadPivotGrid for ASP.NET AJAX
... reports. RadPivotGrid allows easy customization of all data reports. Try now! Use any declarative data source control (AccessDataSource, SqlDataSource, ...

Sign on
Sign On • Join • Forums Home User Name * Password * Remember me next time ( I forgot my password ) SUBMIT YOUR WTF Content Random Article All ...

ComboBox Sample
ComboBox is an ASP.NET AJAX control that, like the AutoCompleteExtender , combines the flexibility of a TextBox with a list of options that users ...

Resources last updated: 12/16/2015 9:19:54 AM