.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

GridView EditItem FileUpload validation

Posted By:      Posted Date: September 02, 2010    Points: 0   Category :ASP.Net
Hey allI am using a gridview that contains an asp:fileupload so that when the user clicks 'edit' they can upload a pdf. I need to validate the size of the file, it needs to be less then a certain size. I tried to use a custom validator, but it never get called when the user updates. Is there a way to do this? How can I validate the file size on edit in the gridview?Thank youAaron

View Complete Post

More Related Resource Links

Server side validation of Fileupload control not working



I've tried this method in my code behind to try and validate that the Fileupload control has a file or not. I get the error message the the event "Server Validate" cannot be found. Can anyone tell why? Thanks.

Public Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate

' Get file name

        Dim uploadAvatar As FileUpload = DirectCast(AdvertisementForm.FindControl("uploadAvatar"), FileUpload)

        Dim UploadFileName As String = uploadAvatar.PostedFile.FileName

        If UploadFileName = "" Then
            ' There is no file selected
            args.IsValid = False
            Dim Extension As String = UploadFileName.Substring(UploadFileName.L

how to apply validation controls on Gridview which is created dynamically

 hi, i created a gridview with two columns and 8 rows dynamically. All the rows are empty and editable at runtime. I am giving column names for this grid from some other .aspx page by passing column names using querystring.Because i am using this grid for three different pairs of column names.  i would like to know how to apply Required Field Validator, Regular Expression Validator  and Range Validator on Gridview textboxes. So that by using those validators i want to validate user inputs. And i would also like to know how to add rows at runtime for this grid. I am using ASP.net 2.0 and C#.net for this.(Visual Studio 2005) The code i am using to create gridview is below. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="LoadData.aspx.cs" Inherits="LoadData" %>  <form id="form1" runat="server">  <div> <asp:GridView ID="GrdDynamic" runat="server" AutoGenerateColumns="False" ForeColor="#333333" BorderColor="GradientInactiveCaption" BorderStyle="Solid" style="z-index: 108; left: 24px; position: absolute; top: 13px">  <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />  <RowStyle BackColor="#EFF3FB"

Using FileUpload and GridView controls

Hi to all,I have four controls in my page: FileUpload, LinkButton, GridView, and Button.FileUpload - I use the control to browse and open an Excel file in the client machine.LinkButton - I use the control to trigger the method that copies the Excel file to the server, converts the data of Excel file to DataTable, deletes the Excel file, and returns the DataTable.GridView - I use the control to display the data.Button - I use the control to save the data to the database.I did not see any problem until I uploaded the third file that hanged my page. I noticed that every time I upload a file, the page become slower gradually.Each Excel file has 2,000 records, and every time the GridView displays an item, it searches the data on the database. I think, the more the data in the database, the slower the searches can be.To solve this problem, I set the AllowPaging property of GridView to true. The less displaying of items, the less searching of data can be. But, every time I change the page of GridView, I have to bind again the data to the GridView. In order to bind the data, FileUpload must contain the source file, but not because FileUpload frees the file when the page posts back. And I don't want the user browses the file every time he changes the page of GridView. That is very tedious.Does anyone have encountered this kind of problem? Please share us your solution.Your responses

How to make cause validation false for Show Edit buttons in Gridview control

  HI. I am having 2 (dept name, City)dropdownlist, 1 Save button once if we click the save then record will be displayed in grid (Gridview with ShowEditbutton =true and I have Edit logic in my page). But if I click on Edit button then if I try to update the value then it is firing a message "Select dept" because dept dropdown present in the page so I want to make cause validation false for Show Edit buttons (update and cancel). Pleaase tell me Thanks

gridview check box validation using js



i'm using a gridview with checkboxes.i want to validate if checkbox is checked or not on button click event.based on that i've to display a message.for that i used th following function.but it's not working.

function check() {
            var grid = document.getElementById("<%grdOrgRes.ClientID %>");
            if (grid.rows.length > 0) {
                for (i = 1; i < grid.rows.length; i++) {
                    cell = grid.rows[i].cells[0];
                    for (j = 0; j < cell.childNodes.length; j++) {
                        if (cell.childNodes[j].type == "checkbox") {
                            if (cell.childNodes[j].checked==false) {

Gridview Sum validation


Hi All,

Seem to have a problem validating values in a gridview - This is the scenario

I have a webform that allows the user adds values to a cheque amount field and 3 subaccounts fields - the 3 subaccounts have validators in place so they will always total up to what the Cheque amount.

Problem is After the data is added and validated it goes onto a gridview that lets users edit the data - This is where they are able to bypass validating the amounts.

 Is there a way to validate sums in a gridview ?


GridView Selected rows validation


Hi All,


I want some solution for my gridview to validated only selected rows.


What is the senario:


In my gridview there are 1 templatecolumn - Total Balance -txtTotalBalance


1 another templatecolumn - Amount Received -txtAmountReceived


There are checkboxes

I want to compare only that row which is checked with txtTotalBalance with txtAmountReceived  should not be greater than totalbalance.


In current code all rows validating compare validator.That I don't want.


Please give me solution-If possible then please send me the code also..

Thanks in advance

Swapnil Malviya

Multiple Fileupload into the sharepoint document library using Fileupload control inside gridview



how to upload multiple files to the sahrepoint document library using fileupload control inside the gridview.?

this is my form design:


<asp:Gridview id="gridview" runat ="server" autogentatecolum="false">


<asp:TemplateField Headertext="3DFinal" runat="Server">


<asp:FileUpload id="Fileupload1" runat ="Server"/>



<asp:TemplateField Headertext="2DFinal" runat="Server">


<asp:FileUpload id="Fileupload2" runat ="Server"/>



<asp:TemplateField Headertext="2Conceptaul" runat="Server">


<asp:FileUpload id="Fileupload3" runat ="Server"/>







<asp:Button id="Save" runat="server" Text="Save" onClick="btsave-Click"/>



If i click the save button the files should go to the sharepoint document library?

i need to uplaod multiple files to the document libray using file upload inside the gridview..

any one know about this file

Inplace Edit in GridView

In this article I am presenting a different way to look at EditItemTemplate, using which user navigation for editing is reduced and . it looks very different (see screeen shots) then regular implementation of GridView.

GridView Confirmation Box Using JQuery BlockUI in asp.net

JQuery is the most popular JavaScript library. One of the main reasons for its fame is the plugin architecture. Anyone can create a separate library that leverage the JQuery library. In this article we are going to look at the BlockUI library which is used to block the user screen while performing a task.

Textbox Editable GridView in ASP.NET

This article describes how I made a fully editable gridview in C# using ASP.NET 2. The idea is that the GridView looks and works like an Excel spreadsheet. You see all the cells in the table, and you can edit any of the cells you like, and they are automatically updated (i.e. saved to the database). This is very often how people expect data tables to work in web pages, and I've often seen people clicking in vain on un-editable gridview cells, somehow expecting to edit them, and not understanding that they need to click an Edit button at the end of the row.

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

AJAX GridView Checkbox Select All in ASP.Net

In the previous article GridView Select Multiple Rows you learnt the multiple row selection in GridView control. Here you will get the C# code sample to select all the gridview rows using single checkbox server control. You can highlight the selected rows with different color and Font state Bold. If you want to use the selection values on different ASP.Net

AJAX GridView Paging and Sorting using C# in ASP.Net

To enable the GridView Paging and Sorting to update the GridView Data without refreshing the ASP.Net web page AJAX Extension controls are used. UpdatePanel is used to hold the GridView control that triggers the events for the controls placed inside it. By Default UpdatePanel triggers the asynchronous postbacks for its child controls.

GridView Paging Using Ajax in ASP.Net

To enable the GridView Paging and Sorting to update the GridView Data without refreshing the ASP.Net web page AJAX Extension controls are used. UpdatePanel is used to hold the GridView control that triggers the events for the controls placed inside it. By Default UpdatePanel triggers the asynchronous postbacks for its child controls.

Displaying Row Details Tooltip on GridView using JQuery

Continuing exploring JQuery! I decided to implement a feature to display some kind of details related to a row displayed on GridView. For example when displaying employees details on GridView some information might not fit in the GridView because it will make it huge and wide. These infomration can be diplayed as Tooltip. Or when you want to display a picture and some kind of formated text to be diplayed as tooltip when mouse hover on the image.

jQuery: Highlight Gridview Rows with Checkbox

Im learning and experimenting with jQuery and ASP.NET. Below is a simple solution I created to highlight rows in a gridview by clicking on a checkbox next to the row.

Gridview setup:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend