CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > visual_studio.visual_web_developer_2005_express Tags:
Item Type: NewsGroup Date Entered: 9/8/2005 10:08:51 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 6 Views: 599 Favorited: 0 Favorite
7 Items, 1 Pages 1 |< << Go >> >|
ASPQuery
Asp.Net User
How to write code for fileupload in edititemtemplate in gridview9/8/2005 10:08:51 AM

0

Hi,

I have added fileupload control in gridview edititemtemplate.How do i write code for this such that on click of update the file selected by browsing is stored on the server.

Please Help

TIA
Fredrik N
Asp.Net User
Re: How to write code for fileupload in edititemtemplate in gridview9/8/2005 10:30:40 AM

0

Maybe this post on my blog can help you: http://fredrik.nsquared2.com/viewpost.aspx?PostID=292
/Fredrik Norm?n NSQUARED2
Microsoft MVP, MCSD, MCAD, MCT

Cornerstone

My Blog, ASP.Net 2.0 etc
ASPQuery
Asp.Net User
Re: How to write code for fileupload in edititemtemplate in gridview9/8/2005 10:44:59 AM

0

I tried this but it dint work for me.
Im using ASP.net 2.0 VWD tool.
It gave compilation errors saying Fileupload is a type and cannot be used as an expression .

Any idea as to why im getting this error msg.. ??

Let me know if im not dng it the rit way
TIA
John S.
Asp.Net User
Re: How to write code for fileupload in edititemtemplate in gridview9/8/2005 5:12:22 PM

0

I'm having a similar problem in that whenever I try to place an UploadFile control into a FormView the sub I've written for the associated "upload" button loses track of the FileUpload control (also in VWD ASP.NET 2.0). I'm using Visual Basic, and my code recognized the control as long as it's not in the FormView element. The error is "FileUpload1 not declared" where FileUpload1 is the ID of the FileUpload control. Note: If I try to declare the control in my code-behind, it tells me "already declared" if the control lives outside the FormView. I can declare it, but it doesn't appear to exist, however, when I move the control into a FormView.

Am I missing a better way to point to the FileUpload control when embedded in the EditItemTemplate, or is it just a case of it's not meant to/can't be done that way? I haven't been able to find any documentation...

Many thanks in advance for insight/workarounds.

YPradeep23
Asp.Net User
Re: How to write code for fileupload in edititemtemplate in gridview12/17/2005 2:13:38 PM

0

I too have same problem

I have an Employee table with the columns?

EmpId             (int),

Name               (string),

Gender             (Char 1 m/f),

DateOfBirth             (DateTime),

Country             (string),

PhotoPath            (string).

 

Note: In PhotoPath column I am storing only Path to image, which was stored in separate folder.

 

I have a middle tire Employee class to perform all CRUD operations. I want to use FormView control as UI for all operations.

 

In READONLY template, I can display an Employee row easily.

Say?EmpId, Name, Gender, Country ? in a lable control; bind DateOfBirth to calender, and Photo to an Image Control.

 

My Problem is?
How to bind (Twoway) the following in EDIT and INSERT templates?

 

Gender ? Radio Buttons ( O Male, O Female)

Country ? Dropdownlist

PhotoPath - FileUpload

 

In Employee class, I need to read these values and store them in the Database.

I have to take file from FileUpload and save it to Harddisk, and write the path to PhotoPath Column.

 

Please help me in it. Thank you in advance.

 

Pradeep

 

mail2sliang@yah
Asp.Net User
Re: How to write code for fileupload in edititemtemplate in gridview1/2/2006 10:01:36 PM

0

I tried the same example but I get a different problem.  My page compiled fine but when I run it, it gets this error when updating the Image cell of my data base:

sql_variant is incompatible with image

Then I check the parameter data type.  In my web page source code, the data type for Image is Object.  I keep thinking this could be the problem because in .NET 1.1, I used to update data cell of Image type useing the SqlDbType.Image data type.

I tried replacing my datasource's update parameter with new "SqlParameter", it will not compile stating cannot convert from System.Data.SqlClient.SqlParameter to System.Web.UI.WebControls.Parameter.

My code looks like this:

PowerEastSqlDataSource.UpdateParameters.Remove(PowerEastSqlDataSource.UpdateParameters["Image"]);
        SqlParameter p = new SqlParameter("Image", SqlDbType.Image);
        PowerEastSqlDataSource.UpdateParameters.Add(p);

Not sure what to do here.  BTW, I am using Visual Web Developer 2005 Express and SQL 2005 Server Express.

 

mail2sliang@yah
Asp.Net User
Re: How to write code for fileupload in edititemtemplate in gridview1/3/2006 8:00:25 PM

0

The Personal Web Site Starter Kit has great sample code on how to upload image to data base.  The link is shown below:

http://www.asp.net/default.aspx?tabindex=5&tabid=41

Or just go to www.asp.net > Downloads.

This template project's Photo.aspx page uses

<asp:ObjectDataSource ID="ObjectDataSource1" Runat="server" TypeName="PhotoManager" SelectMethod="GetPhotos" InsertMethod="AddPhoto" DeleteMethod="RemovePhoto" UpdateMethod="EditPhoto" >

In the PhotoManager, check out the AddPhoto method:

public static void AddPhoto(int AlbumID, string Caption, byte[] BytesOriginal) {

using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Personal"].ConnectionString)) {

using (SqlCommand command = new SqlCommand("AddPhoto", connection)) {

command.CommandType = CommandType.StoredProcedure;

command.Parameters.Add(new SqlParameter("@AlbumID", AlbumID));

command.Parameters.Add(new SqlParameter("@Caption", Caption));

command.Parameters.Add(new SqlParameter("@BytesOriginal", BytesOriginal));

command.Parameters.Add(new SqlParameter("@BytesFull", ResizeImageFile(BytesOriginal, 600)));

command.Parameters.Add(new SqlParameter("@BytesPoster", ResizeImageFile(BytesOriginal, 198)));

command.Parameters.Add(new SqlParameter("@BytesThumb", ResizeImageFile(BytesOriginal, 100)));

connection.Open();

command.ExecuteNonQuery();

}

}

}

 

Then in the SQL database, check out the AddPhoto store proceedure:

ALTER PROCEDURE AddPhoto

@AlbumID int,

@Caption nvarchar(50),

@BytesOriginal image,

@BytesFull image,

@BytesPoster image,

@BytesThumb image

AS

INSERT INTO [Photos] (

[AlbumID],

[BytesOriginal],

[Caption],

[BytesFull],

[BytesPoster],

[BytesThumb] )

VALUES (

@AlbumID,

@BytesOriginal,

@Caption,

@BytesFull,

@BytesPoster,

@BytesThumb )

RETURN

This is a better way to upload files to DB than the way I use before.  By using a store proceedure, the processing is off loaded to the DB server from Web Server.  Though, these two servers are the same PC so it did not make any improvement in this regard.  But this pattern is more scalable.

7 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
How to write code for fileupload in edititemtemplate in gridview ... I have added fileupload control in gridview edititemtemplate.How do i write code for this such that on click of update the file selected by ...
GridView and FileUpload control and EditItemTemplate - ASP.NET Forums Is it possible to place a FileUpload control inside the EditItemTemplate of a GridView control? How do I access this control in the ...
Fredrik Normén's Blog - NSQUARED2 Feb 24, 2005 ... Any fool can write code that a computer can understand. ... To add a FileUpload control to your GridView, you first need to add an ItemTemplateField. ... you can add the FileUpload ot the EditItemTemplate: ...
Online .NET Help, Code Guru, Source Codes: How to write code for ... How to write code for fileupload in edititemtemplate in gridview. In the PhotoManager, check out the AddPhoto method: public static void AddPhoto(int ...
GridView Row Edit, Delete and Update « Devils Work DotnetRuler on multiple file upload control U… ... The following is how we write asp.net GridView web server control code in aspx page. ... EditItemTemplate as the name itself it is the content to display for the items in the ...

How to write code for fileupload in edititemtemplate in gridview ... I have added fileupload control in gridview edititemtemplate.How do i write code for this such that on click of update the file selected by ...
Upload Image to Database - ng.asp-net-forum.getting_started How to write code for fileupload in edititemtemplate in gridview ... In my web page source code, the data type for Image is Object. ...
Help: How to open a modal window after logged in - ng.asp-net ... How to write code for fileupload in edititemtemplate in gridview ... help: how to open a modal window after logged in · administer membership on standalone ...
Bypassing basic authentication - ng.asp-net-forum.security How to write code for fileupload in edititemtemplate in gridview ... bypassing basic authentication · question about activedirectorymembershipprovider and ...






double click tab to close??

deploy a website

lost drag and drop capabilities from the tool box

mssql hosting help

problem to retrieve output value from stored procedure

how to refer a sqldatasorce with gridview's datasourceid

timer on project work?

visual web developer 2005 express edition will not install!

versions of project

asp.net c# and sql server 2005 express connection problems

problem using masters pages

visual web developer hangs

problem displaying results of a calculation in a label web control

how to user event of usercontrol

installation woes

what does the "clean solution" option under the build menu of vwd do?

asp.net server

debugging in vwd 2005?

gridview enablesortingandgroupingbycallback

bind gridview to view

a basic question regarding asp.net installed programs...

problem changing a label in the gridview's footer

debug not working in ie7

first question

login contro..unable to see web admin webpage

is use for sqldatasource control to fetch data is compulsory??

getting started with visual web developer 2005 express edition

vwd kills my machine

error while renaming controls

tab control

   
  Privacy | Contact Us
All Times Are GMT