Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7403859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:10:13+00:00 2026-05-29T05:10:13+00:00

This is my part of code for the grid view <asp:GridView ID=gridViewCourse runat=server AutoGenerateColumns=False

  • 0

This is my part of code for the grid view

   <asp:GridView ID="gridViewCourse" 
            runat="server" 
            AutoGenerateColumns="False" 
            onrowcancelingedit="gridViewCourse_RowCancelingEdit" 
            onrowdeleting="gridViewCourse_RowDeleting" onrowediting="gridViewCourse_RowEditing" 
            onrowupdating="gridViewCourse_RowUpdating" 
            onrowcommand="gridViewCourse_RowCommand" 
            datakeynames="CourseId"

            ShowFooter="True">
         .....

    <asp:TemplateField HeaderText="Fichier">
                    <EditItemTemplate>
                        <asp:FileUpload ID="FileUploadFichier" CssClass="upload" runat="server" Text='<%#Eval("Fichier") %>'/>  
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblFichier" runat="server" Text='<%#Eval("Fichier") %>'/>
                    </ItemTemplate>
                    <FooterTemplate>
                        <asp:FileUpload ID="FileUploadFichier" CssClass="upload" runat="server"  />

                    <asp:RequiredFieldValidator ID="rfvFichier" runat="server" ControlToValidate="FileUploadFichier" Text="*" ValidationGroup="validaiton"/>
                    </FooterTemplate>

        ....

This my method “onrowcommand=”gridViewCourse_RowCommand””

        Protected Sub gridViewCourse_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
    If e.CommandName.Equals("AddNew") Then
        Dim txtId As TextBox = DirectCast(gridViewCourse.FooterRow.FindControl("txtftrId"), TextBox)
        Dim txtCours As TextBox = DirectCast(gridViewCourse.FooterRow.FindControl("txtftrCours"), TextBox)
        Dim txtPrix As TextBox = DirectCast(gridViewCourse.FooterRow.FindControl("txtftrPrix"), TextBox)
        Dim txtTutor As TextBox = DirectCast(gridViewCourse.FooterRow.FindControl("txtftrTuteur"), TextBox)
        con.Open()
        Dim cmd As New SqlCommand(((("insert into Courses(CourseID,CourseName,Price,Tutor) values('" + txtId.Text & "','") + txtCours.Text & "','") + txtPrix.Text & "','") + txtTutor.Text & "')", con)
        Dim result As Integer = cmd.ExecuteNonQuery()
        con.Close()
        If result = 1 Then
            BindCoursesDetails()
            lblresult.ForeColor = Color.Green
            lblresult.Text = " Details inserted successfully"
        Else
            lblresult.ForeColor = Color.Red
            lblresult.Text = " Details not inserted"


        End If
    End If

    Dim upload As FileUpload = DirectCast(gridViewCourse.FindControl("FileUploadFichier"), FileUpload)

    upload.SaveAs((Server.MapPath(Request.ApplicationPath & "/CoursesFiles/" & Path.GetFileName(FileUpload1.PostedFile.FileName))))
End Sub

The problem is The cast to upload (As FileUpload) contain nothing after…
The others are good and effective…

How I can acces to the FileUpload1 and save it ?

Thanks Frank

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:10:14+00:00Added an answer on May 29, 2026 at 5:10 am
             Protected Sub gridViewCourse_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
    If e.CommandName.Equals("AddNew") Then
        Dim txtId As TextBox = DirectCast(gridViewCourse.FooterRow.FindControl("txtftrId"), TextBox)
        Dim txtCours As TextBox = DirectCast(gridViewCourse.FooterRow.FindControl("txtftrCours"), TextBox)
        Dim txtPrix As TextBox = DirectCast(gridViewCourse.FooterRow.FindControl("txtftrPrix"), TextBox)
        Dim txtTutor As TextBox = DirectCast(gridViewCourse.FooterRow.FindControl("txtftrTuteur"), TextBox)
    
    Dim upload As FileUpload = DirectCast(gridViewCourse.FindControl("FileUploadFichier"), FileUpload)
    
    upload.SaveAs((Server.MapPath(Request.ApplicationPath & "/CoursesFiles/" & Path.GetFileName(FileUpload1.PostedFile.FileName))))
        con.Open()
        Dim cmd As New SqlCommand(((("insert into Courses(CourseID,CourseName,Price,Tutor) values('" + txtId.Text & "','") + txtCours.Text & "','") + txtPrix.Text & "','") + txtTutor.Text & "')", con)
        Dim result As Integer = cmd.ExecuteNonQuery()
        con.Close()
        If result = 1 Then
            BindCoursesDetails()
            lblresult.ForeColor = Color.Green
            lblresult.Text = " Details inserted successfully"
        Else
            lblresult.ForeColor = Color.Red
            lblresult.Text = " Details not inserted"
    
    
        End If
    End If
    

    End Sub

    I have to put the cast before BindCoursesDetails()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Gridview with these parameters: <asp:GridView runat=server ID=ItemGrid CssClass=Grid AutoGenerateColumns=false AutoGenerateDeleteButton=true OnRowDeleting=RowDeleting
I am trying to learn and writting this part of code. while testing few
This part of my code works fine: #include <stdio.h> int main(){ //char somestring[3] =
It seems that this part of my code is where the exception occurs: c
I just started learning C but I don't understand this part of the code.
this is part of my code which reads an http response. It's supposed to
The code we're using is straightforward in this part of the search query: myCriteria.Add(
Note : The code in this question is part of deSleeper if you want
Part of my code goes like this: while(1){ my $winmm = new Win32::MediaPlayer; $winmm->load('1.mp3');
I have this code to run a slideshow (this is only part of what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.