Link to home
Start Free TrialLog in
Avatar of adoliv
adolivFlag for South Africa

asked on

Storing Data from a Column in a Variable

Hi Experts

Okay I am creating a ZIP File containing multiple images files, but the filepaths that I require are results from a SQL Query that populate a Gridview.

Process Flow: User Provides A Start Date And End Date > Button 1 Click > SQL Query > Populate Gridview With Results > If User is happy with results > 2nd Button Click > Download ZIP File.

I need to know how I can store all the data in numerous records in one column of the Gridview into a String Variable(Please supply the example code required because I have searched the net for examples for a while and come out with nothing)

Example
Id      FileName      Extension
1      image1      jpg
2      image2      gif
3      image3      jpg

Basically I want to be able to store all the values under the FileName column in a String Variable called "items" (Please view attached Code Snippet or Attached File).
Line 3 = New String() {"", "c:\test\Copy of one.txt", "c:\test\one.txt", "c:\test\o-fone.txt"}

I think is needs to look like this
New String() {"", + items}
code.txt
Avatar of kaylanreilor
kaylanreilor
Flag of Luxembourg image

First use a StringBuilder object instead of a string. Then I suppose you will have to loop through your dataset to read each matching field from the rows and then concatane the result into your StringBuilder object.
Here is some examples of how to play with data:
http://bytes.com/groups/net-c/251798-loop-through-dataset-get-values-vb-net
http://msmvps.com/blogs/simpleman/archive/2005/06/24/54832.aspx
http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.adonet/topic4071.aspx
http://forums.asp.net/p/1059398/1516788.aspx
Avatar of adoliv

ASKER

Cant I just Loop through the Gridview? Rather than having to create a seperate Dataset, populating the dataset and looping through that? It would be easier because I have already setup the query to place the received results within a Gridview.
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial