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

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

editing gridview in a formview in a formview... yikes.

Posted By:      Posted Date: September 07, 2010    Points: 0   Category :ASP.Net
Oh dear - I don't know how it came to this but I could really do with a bit of help.I have a gridview which has editable columns. The gridview lives in a formview, which lives in another formview.Inside one column is an end date. This column has a textbox which gets it's value when I choose a date from a calendar control. However, when I choose a date from the calendar control, the program crashes instead of populating the text box.Here is the page and the selectedIndexChanged sub for the piece of work I'm trying to accomplish...dim rowid as integer Protected Sub Calendar2_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) 'Assign value to textbox from Calendar Dim tmp As FormView = Me.FormView1.FindControl("formview3") Dim tmpgridview As GridView = tmp.FindControl("gridview2") CType(tmpgridview.Rows(rowid).FindControl("textbox3"), TextBox).Text = CType(tmpgridview.Rows(rowid).FindControl("Calendar2"), Calendar).SelectedDate End Sub Gridview2 is inside formview3 inside formview1I have included the whole page below, but the problem area is gridview2<%@ Page Language="VB" MasterPageFile="~/myMasterPage.master" AutoEventWireup="false" CodeFile="user_profile.aspx.vb" Inherits="user_profile" title="View Profile - A

View Complete Post

More Related Resource Links

Referencing a linkbutton which is within a formview which is within a gridview template

Hello forum.  I have a gridview (gridview1) which contains a formview(formview1) which formview contains a linkbutton(linkbutton1).  I'm trying to  get the linkbutton's click event to redirect to page2 with a querystring value that's the linkbutton's text value. Something like this:   Response.Redirect("~/Page2.aspx" + "?" + "E=" + LinkButton1.Text)How do I reference LinkButton1's text value in code behind so I can pass it to Page2 through the query? Thank you  

URGENT: Gridview/formview with entitydatasource

I'm trying to get a Gridview/formview working but when using entitydatasource,
How is it done with the entity framework?  I want the formview to display the data selected in the gridview for edit and I want to insert new data from the formview to the grid.
Any links or help is appreciated. This is urgent!!


New Record Button for FormView when GridView on same form


I have a GridView and FormView on the same form - it all seems to work OK connected up together.

How can I offer the user a "New Record" button / link directly when they hit the page? At present it's only when they select a record from the grid that a New link appears.

Also on  a related note, if the user deletes a record, I have the grid refreshing, but the deleted record stays put on the formview - can I refresh this, or lose the formview until they select another record from the Grid?


Enable Editing option not available in FormView


I'm using Visual Web Developer 2010 and SQL Server 2008 R2.  I have a table that does not have any uniqueidentifier columns.  It's got a UserName column that I have set as a Primary Key and a few other varchar columns.  I'm trying to create a web page with a FormView control that will allow individual users to enter or edit their information after their record has been retrieved.

I'm dragging the FormView onto the form, selecting SQL Database and my data connection, and selecting Specify a Custom SQL starement or stored procedure.  Then I enter my SQL statement using Query Builder and test it using Test Query.  It retrieves the record - no problem.  I then hit Finish and it returns me to the Design View of my web page.  But to my dismay, the list of enableable features for my FormView is limited to only

  • Enable Dynamic Data support
  • Enable Paging

The only option I actually need is Enable Editing but it's not there.  In all the online video tutorials that I've seen on the subject, the Enable Editing option is always there and there's never any mention of it not being there under certain circumstances.  What might be the cause of the Enable Editing option missing from my FormView? 

Enable Editing Not Available When Using FormView


I have Visual Web Developer 2010 Express on Vista Ultimate x64.  I've watched various video tutorials on how to set up and use the GridView and FormView.  However, I have been unable to get the FormView to make the Enable Editing option available.  I need to create a web page that retrieves one record and allows the user to edit the displayed data.

I'm using SQL Server database and I'm connecting the FormView to SqlDataSource1.  I'm setting up a custom SQL statement using Query Builder.  I test the SQL and it returns the selected record - no problem.  The table I'm accessing has no uniqueidentifier columns, but it does have a Primary Key column.  The rest of the columns are just varchar, tinyint, and date.

But after I'm done setting up the FormView, I notice that the Enable Editing option is not available.  What might be causing the Enable Editing option to not be available?  Thanks.

End user linking many to many relationship - how to setup process in FormView / GridView / other?


Having a serious brain fart and can't seem to think of a way to handle the following:

Our business has 17 stores who all perform a nightly reconciliation comparing physical totals to our point of sale z-out reports.  They enter the data into a DailyReconciliation table.  This is all done by store management.  Then at our corporate office our asst controller takes each days receipt totals for cash, electronic check, Amex, and all other Credit cards for every store and compares them to the bank statement lines.  We are attempting to move to a manage exceptions approach in order to save time.  She's barely able to keep up with work load and we are looking at adding 6 new stores by the end of the year.  I've written SSIS package to upload the bank statements to a BankStatement table and perform a link to the receipt id from the DailyReconciliation table where the amounts match in dollar and transaction type and fall within an acceptable date range difference.  It's all working beautifully EXCEPT that sometimes the Amex totals on the bank statement include multiple days totals for a particular store.  I set all this up under the impression that it was a One to Many relationship (One DailyReconciliation receiptID to Many BankStatement bank_recordID -- in other words 1 store's reconciliation record for a day would include Amex tot

Editing the Data in a GridView

In addition to deleting a GridView's underlying data, another common need is to allow end users to edit the data displayed in a GridView. With ASP.NET 1.x's DataGrid control, editing the data is certainly possible, but requires creating three event handlers and writing a dozen or so lines of code. With the GridView and ASP.NET 2.0, it is possible to create an editable GridView without writing a single line of code! All of the necessary functionality is encapsulated within the GridView.

The GridView allows editing on a row-by-row basis. An editable GridView contains an additional column with an Edit button in each row. When the end user clicks on an Edit button that row becomes editable, causing the Edit button to change to Update and Cancel buttons and the other columns to become TextBoxes. The end user can then update one or more column values and click Update to save their changes.

How Do I Enable Inline GridView Editing?

Now that you have created a site with Edit and Details views, how do you enable inline editing in a GridView control? This video shows you how, and also touches on routing.

Gridview with a dropdown list for editing


Hello. I am working through Scott Mitchell's ASP.Net in 24 hours book. I am finishing the photo album project.

I have a GridView that retrieves a list of uploaded photo rows for the logged-in user.
The GridView is for editing and deleting rows.

The photo Category field in the Gridview is a dropdown list. The text entry field was deleted after converting this field to a Template.

Like the uploaded photos, these Categories are user-specific. They are created in another web page.

Users also have the option to select "none" for the category when they upload an image.

For the GridView:  The Category ID field's ItemTemplate and EditItemTemplate both have a " - None - " choice added to them.

I am getting this error:

'pictureReadOnlyCategories' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value


Note: The ID for the ItemTemplate for that dropdown list is the ID listed above in the error: "pictureReadOnlyCategories".


Am I missing some step in this process of changing a GridViews text field to a dropdown that can be used for editing? I went through the book's instructions three times.

Here is my code for the dropdown list and a screenshot of the Design

Formview LinqData source not allowing updates


OK, I'm confused.  I've set up a formview with a Linqdata source to allow users to edit records.  When I run it, edit data and submit, it blows up and tells me "Linq datasource6  does not support the Select property when the Delete, Insert or Update operations are enabled."  I googled that warning and saw a couple of posts on this forum saying the problem is the slect statement has to be removed from the Linq data source for it to allow updates. 

But if I remove the select statement then how do I show the user specific info on pageload?   plus I thought the two way databind was an advantge of the datasource control.




FormView -- Parameters and asp:Table


I've already solved this problem to my satisfaction, I just want to know WHY it works this way.

I have a FormView control bound to an ObjectDataSource.  Let's say our data source is a hypothetical table with three columns:  id, name, age.  Why is it that when I use the <asp:Table> element inside of the FormView, the parameter values are not set, but when I use the standard <table> tag, it works fine?

This seems like a .NET problem to me.  I expect the <asp:Table> element to work in the same way as <table> because they are, for all intents and purposes, the same thing.  Am I missing something?

DropDownList within FormView Error

I have a FormView which works find and I have added a new DropDownList within the form which references another table to which I need to select a value,
I have added the dropdownlist2 and setup a new connection string to this, when I run the page I get this error:

Could not find control 'DropDownList2' in ControlParameter 'CurrencyID'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Could not find control 'DropDownList2' in ControlParameter 'CurrencyID'.
any help would be greatly

Help ~~ How to Update Binary Image on Formview

Hi All ~~ I'm confused, Can i have some help please... Thanks
Database: Books
uid dataType uniqueidentifier
Cover dataType image 
aspx :
 <asp:FormView ID="FormView1" runat="server" BackColor="LightGoldenrodYellow"   BorderColor="Tan" BorderWidth="1px" CellPadding="2" DataKeyNames="uid"     DataSourceID="SqlDataSource1" ForeColor="Black" Width="525px">
         <table class="table_width">
                 <td class="imageWidth">
                     <asp:Image ID="Image1" runat="server" Height="245px" 
                                       ImageUrl='<%# IIF(Eval("Cover") Is DbNull.Value, "~/Styles/Global/CFZ-No-Images.png", Eval("uid", "~/ImageServices.ashx?BooksID={0}")) %>' Width="180px" />

Help with displaying formview based on dropdownlist


I have a formview1 with a dropdownlist1 in the insert template. Based on the value of that dropdownlist I would like to display a second formview on the same page in insert mode so that I can write data to two different tables.

How can I accomplish this?

Is this the best way to do it?



FormView KeepInEditMode=true isn't retaining values


I have an "Edit Page" in my application. It uses a FormView bound to an EntityDataSource.

I have a handler setup for the FormView OnItemUpdated event. If an exception occurs (such as foreign key constraints or non date vales entered in a date colum, etc.), then I set the "KeepInEditMode=true". This is SUPPOSED to retain the user entered values on all of the text boxes instead of rebinding the FormView to the data again and clearing those text boxes. (Right?)

Well, it isn't working...

I have stepped through the code via the debugger and the "KeepInEditMode" does get set to true, but as soon as the page reloads, the values revert back to the original database values (the data is being rebound).

I should also mention that I am setting "ExceptionHandled" to true. I am doing this because I am handling the Exception by displaying an error in a specific area of the page and if I dont mark it as handled, IE generates an Exception popup.

Any ideas?

Gridview extends past edge of div and page when editing users


I have a gridview pulling all data from one user. This gridview has an edit button and when that is clicked the gridview becomes too wide for the div/screen and I get a scroll bar. Since this gridview can only have one user in it anyway is it possible to display each field on seperate lines instead?

FormView Text Field Being Set by A Drop Down List


Hello, I have a FormView which is used to insert a record into a database.  Outside of this formview i have a drop down list, I want to grab the value from that drop down list and set one of the text fields within the formview to it's currently selected value.  I've tried the following code, but the dynamic categorytextbox line is what seems to not be working.

                    <asp:DropDownList ID="ddlCategory" runat="server" AutoPostBack="True" 
DataSourceID="SqlDataSourceCategory" DataTextField="CategoryName"
DataValueField="CategoryID" Width="200px">

                            <asp:TextBox ID="CategoryIDTextBox" runat="server" 
Text='<%# Bind("CategoryID") %>' Visible="False" />

        protected void FormView1_DataBound(object sender, EventArgs e)
dynamic varCategory = ddlCategory.SelectedValue;
dynamic categoryTextBox = FormView1.FindControl("CategoryIDText
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