Advertisement

02.11.2008 at 12:10PM PST, ID: 23154190
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Gridview - Add/remove rows on the fly without a database

I have a gridview created blank on the fly. At the end of every row, there's an Add/Remove link button that will add/remove rows. I have one textbox field they have to enter.
As they add new rows, the text they have entered in previous rows has to be displayed. Although I see this text (in debug mode), I can't display it in the table as I loop through the gridviewrow.

The error is: "Type of value has a mismatch with column type"

Thanks
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
Here's the sub that builds a blank gridview with one row:
    Private Sub BuildUploadTable()
        Dim dt As New DataTable
        Dim dc As New DataColumn("description")
        dtFiles.Columns.Add(dc)
        Dim dr As DataRow = dtFiles.NewRow
        dr("description") = "None"
        dtFiles.Rows.Add(dr)
        dsFiles.Tables.Add(dtFiles)
        'gFiles.DataSource = dsFiles
        gvFiles.DataSource = dtFiles
        gvFiles.DataBind()
        gvFiles.Visible = True
    End Sub
 
Here's the part that's problematic:
    Protected Sub gvFiles_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvFiles.RowCommand
        If dtFiles.Rows.Count = 0 Then
            dtFiles.Columns.Add("tbDesc", GetType(TextBox))
            dtFiles.Columns.Add("Add", GetType(ButtonColumn))
            dtFiles.Columns.Add("Remove", GetType(ButtonColumn))
        End If
        'Convert datagrid to dt
        Dim gr As GridViewRow
        Dim nr As DataRow
 
        For Each gr In gvFiles.Rows
            nr = dtFiles.NewRow
'BEGIN PROBLEM
            nr(0) = CType(gr.FindControl("tbDesc"), TextBox).Text 
            nr(1) = "Add"
            nr(2) = "Remove"
'END PROBLEM
            dtFiles.Rows.Add(nr)
        Next
 
        If e.CommandName = "Add" Then
            'Add new row to dt
            nr = dtFiles.NewRow
            dtFiles.Rows.Add(nr)
            dsFiles.Tables.Add(dtFiles)
            gvFiles.DataSource = dtFiles
            gvFiles.DataBind()
            gvFiles.Visible = True
        ElseIf e.CommandName = "Remove" Then
            dtFiles.Rows.RemoveAt(gvFiles.Rows(e.CommandArgument).RowIndex)
            dsFiles.Tables.Add(dtFiles)
            gvFiles.DataSource = dtFiles
            gvFiles.DataBind()
            gvFiles.Visible = True
        End If
    End Sub
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: tucson
Solution Provided By: TheLearnedOne
Participating Experts: 1
Solution Grade: A
Views: 61
Translate:
Loading Advertisement...
02.11.2008 at 02:22PM PST, ID: 20870912

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.15.2008 at 02:37PM PST, ID: 20906671

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.15.2008 at 02:41PM PST, ID: 20906699

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.19.2008 at 06:46AM PST, ID: 20928728

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.19.2008 at 06:52AM PST, ID: 20928830

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.19.2008 at 10:29AM PST, ID: 20931099

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.20.2008 at 07:18AM PST, ID: 20938554

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.20.2008 at 08:32AM PST, ID: 20939348

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.20.2008 at 08:39AM PST, ID: 20939439

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.20.2008 at 09:03AM PST, ID: 20939711

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.20.2008 at 09:10AM PST, ID: 20939788

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.20.2008 at 09:24AM PST, ID: 20939904

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.20.2008 at 09:27AM PST, ID: 20939929

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.20.2008 at 09:50AM PST, ID: 20940113

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.20.2008 at 10:26AM PST, ID: 20940441

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.20.2008 at 10:35AM PST, ID: 20940489

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.20.2008 at 10:35AM PST, ID: 20940492

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.20.2008 at 10:35AM PST, ID: 20940494

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.20.2008 at 11:03AM PST, ID: 20940726

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.20.2008 at 01:00PM PST, ID: 20941906

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • Automotive
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Displays / Monitors
  • Handhelds / PDAs
  • Components
  • Peripherals
  • Laptops/Notebooks
  • Servers
  • Misc
  • Apple
  • Embedded Hardware
  • Networking Hardware
  • Storage
  • Desktops
  • New Users
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMware
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Virtualization
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • Web Computing
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Consulting
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMware
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Automation
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Web Services
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Web Computing
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Lounge
  • Business Travel
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
  • Automotive
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
02.11.2008 at 02:22PM PST, ID: 20870912

Rank: Genius

You should be able to add/insert rows into the DataTable datasource, and rebind to get new rows.

Bob
 
02.15.2008 at 02:37PM PST, ID: 20906671
I added and removed rows successfully in the sample code above. The problem is displaying the previous row contents when a new row is added. I can see the textbox value in the table and dataset in debug mode but can't assign those values back into the gridview to be displayed.
 
02.15.2008 at 02:41PM PST, ID: 20906699

Rank: Genius

If you are correctly re-binding the GridView to the DataTable after adding a row, I don't see why it shouldn't work as expected.

Bob
 
02.19.2008 at 06:46AM PST, ID: 20928728
Please look at my code snippet. I can see the values in the dataset and datatable but once I rebind it, it's not in the gridview. Thanks.
 
02.19.2008 at 06:52AM PST, ID: 20928830

Rank: Genius

I did look at your code, and I was trying to say that there is some missing bit of information to show why you are having a problem, because the code doesn't show it.

Bob
 
02.19.2008 at 10:29AM PST, ID: 20931099
EnableViewState is True for the gridview.
I'm not sure what else to look for (what "missing bit"?) It doesn't show what?
 
02.20.2008 at 07:18AM PST, ID: 20938554
It seems like my problem is that I'm trying to store the fileupload and textbox objects into the gridview AS WELL AS trying to store the string values of the fileupload and the textbox contents. And I can't do that? When I preview the datatable, the objects are in there but the values can't be displayed because the gridview also needs to display the objects.
I tried a placeholder but it doesn't work either.
 
02.20.2008 at 08:32AM PST, ID: 20939348

Rank: Genius

Are you saying that you have a TemplateField defined with a FileUpload control and a TextBox in the same template?

Bob
 
02.20.2008 at 08:39AM PST, ID: 20939439
No they are 2 in different template columns. But I want to display the fileupload and textbox objects and their perviously entered values each time a new blank row is added.

In this example: http://geekswithblogs.net/casualjim/archive/2006/05/04/77151.aspx, you keep the fileupload/textbox objects in the footer row and adds the records into the gridview rows as labels. I want every row to be like the footer row in this example. I may just decide to to the footer row method since I'm not sure if what I'm trying to accomplish can be done in a gridview.
 
02.20.2008 at 09:03AM PST, ID: 20939711

Rank: Genius

How do you define your columns?  Through the designer?  In code?

You can't do this:

           dtFiles.Columns.Add("Add", GetType(ButtonColumn))
            dtFiles.Columns.Add("Remove", GetType(ButtonColumn))
 
And, then this:

            nr(1) = "Add"
            nr(2) = "Remove"

The type is not string, so you would need to add a ButtonColumn object.  I don't think that is what you meant to do.

Bob
 
02.20.2008 at 09:10AM PST, ID: 20939788
I added the columns through the designer.
The code below displays the blank rows with the appropriate controls when I added a new row.
The problem is that I can't display the values that were entered in the previous row as they add new rows. Every row is blank. The datatable and gridview only store the controls and can't display the values.
In the example below, I can't do:
nr(0) = fileU.FileName
nr(1) = tb.text, which is what I want to do.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
       For Each gr In gFiles.Rows
            nr = dtFiles.NewRow
            fileU = CType(gr.FindControl("FileToUpload"), FileUpload)
            tb = CType(gr.FindControl("tbDesc"), TextBox)
            bAdd = CType(gr.FindControl("btnAdd"), LinkButton)
            nr(0) = fileU
            nr(1) = tb
            nr(2) = bAdd
            dtFiles.Rows.Add(nr)
        Next
            gFiles.DataSource = dtFiles
            gFiles.DataBind()
Open in New Window
 
02.20.2008 at 09:24AM PST, ID: 20939904

Rank: Genius

So, you want a dynamic number of file uploads, instead of a fixed number of rows (the usual way of doing business)?

Bob
 
02.20.2008 at 09:27AM PST, ID: 20939929
Yes, because the range of number of uploads varies from 1 to 30.
 
02.20.2008 at 09:50AM PST, ID: 20940113

Rank: Genius

Does the <Add> button just insert a new row to upload?  After you upload are you keeping track of the file name?

Bob
 
02.20.2008 at 10:26AM PST, ID: 20940441
The upload will occur as a batch, at the very end.
Yes, the Add button adds an empty row. I need to keep track of all the previous rows already entered before finally doing a batch upload.
 
02.20.2008 at 10:35AM PST, ID: 20940489

Rank: Genius

Attached is my version of a dynamic uploader page.

Bob
 
02.20.2008 at 10:35AM PST, ID: 20940492

Rank: Genius

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="DynamicUploader.aspx.vb"
    Inherits="DynamicUploader" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Untitled Page</title>
    <style type="text/css">
        body { font-family: Tahoma; font-size: 10pt; }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:GridView ID="GridView1" runat="server" Height="50%" Width="100%" AutoGenerateColumns="False"
                Font-Names="Tahoma" Font-Size="10pt" OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound">
                <Columns>
                    <asp:TemplateField HeaderText="Upload">
                        <ItemTemplate>
                            <asp:FileUpload ID="FileUpload" runat="server" Font-Names="Tahoma" Font-Size="10pt"
                                Width="100%" />
                            <asp:TextBox ID="FileName" runat="server" Width="100%" Visible="false" Text='<%# Eval("FileName") %>'></asp:TextBox>
                        </ItemTemplate>
                        <HeaderStyle Width="30%" />
                    </asp:TemplateField>
                    <asp:BoundField DataField="Description" HeaderText="Description">
                        <HeaderStyle Width="40%" />
                    </asp:BoundField>
                    <asp:ButtonField CommandName="Add" Text="Add">
                        <HeaderStyle Width="5%" />
                    </asp:ButtonField>
                </Columns>
            </asp:GridView>
        </div>
    </form>
</body>
</html>
Open in New Window
 
02.20.2008 at 10:35AM PST, ID: 20940494

Rank: Genius

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
Imports System
Imports System.Data
 
Partial Public Class DynamicUploader
  Inherits System.Web.UI.Page
 
  Private _UploadData As DataTable
 
  Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
 
    If Not Page.IsPostBack Then
      Me.CreateUploadTable()
    Else
      _UploadData = DirectCast(Session("UploadData"), DataTable)
    End If
 
    Me.GridView1.DataSource = _UploadData
    Me.GridView1.DataBind()
  End Sub
 
  Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
    If e.CommandName = "Add" Then
      Me.SaveUploadedFileNames()
 
      Dim dr As DataRow = _UploadData.NewRow()
 
      _UploadData.Rows.Add(dr)
 
      Session("UploadData") = _UploadData
 
      Me.GridView1.DataSource = _UploadData
      Me.GridView1.DataBind()
    End If
  End Sub
 
  Private Sub CreateUploadTable()
    _UploadData = New DataTable("Upload")
 
    _UploadData.Columns.Add("FileName")
    _UploadData.Columns.Add("Description")
 
    Dim dr As DataRow = _UploadData.NewRow()
 
    _UploadData.Rows.Add(dr)
 
    Session("UploadData") = _UploadData
  End Sub
 
  Private Sub SaveUploadedFileNames()
    For i As Integer = 0 To Me.GridView1.Rows.Count - 1
      Dim row As GridViewRow = Me.GridView1.Rows(i)
 
      Dim upload As FileUpload = TryCast(row.FindControl("FileUpload"), FileUpload)
      Dim textBox As TextBox = TryCast(row.FindControl("FileName"), TextBox)
 
      If upload IsNot Nothing AndAlso textBox IsNot Nothing AndAlso textBox.Text.Length = 0 Then
        Dim dr As DataRow = _UploadData.Rows(i)
        dr("FileName") = upload.FileName
      End If
    Next
    Session("UploadData") = _UploadData
  End Sub
 
  Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
    Dim upload As FileUpload = TryCast(e.Row.FindControl("FileUpload"), FileUpload)
    Dim textBox As TextBox = TryCast(e.Row.FindControl("FileName"), TextBox)
 
    If upload IsNot Nothing AndAlso textBox IsNot Nothing Then
      textBox.Visible = (textBox.Text.Length > 0)
      upload.Visible = Not textBox.Visible
    End If
  End Sub
End Class
Open in New Window
Accepted Solution
 
02.20.2008 at 11:03AM PST, ID: 20940726
Thanks, I'm looking into this after lunch.
 
02.20.2008 at 01:00PM PST, ID: 20941906
You are indeed a genius. Thank you for taking the time. You put the fileupload and a textbox in the same template column and hide/unhide the textbox. The textbox is used to store the filename for displaying it further.
Thanks
 
 
02.25.2008 at 02:04PM PST, ID: 20979722
Sorry to open this ticket again. When I upload the files at the end, what's the best way to read/write the files to upload them to the server? Since the upload control is no longer there (just the path is stored in a textbox), I can't call FileUpload.SaveAs method.
Thanks
 
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628