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

Top 5 Contributors of the Month
david stephan
Gaurav Pal
" yc=""><tr>
"><td> <strong> Gender: </ strong> </ td>
Post New Web Links

Referencing Parent FormView from Embedded FormView

Posted By:      Posted Date: September 01, 2010    Points: 0   Category :ASP.Net
Looking for some direction here.  Thanks in advance for any assistance.   I have a scenario where I have a FormView positioned inside another FormView.  Each FormView is connected to a strongly typed ObjectDataSource (DataObjectName).  The parent FormView is a single record in Read Only mode.  The child FormView is defaulted to Insert Mode.  Can someone tell me how to get the Key Field (and even some of the other fields) from the parent FormView to use during Insert in the Child FormView?  I've tried using a combination of the different events (i.e. OnDataBind, OnInserting, etc.) on the child FormView.  This seems like it should be real simple but I'm just not getting it.   My structure looks as follows:<asp:objectdatasource id="vendor" dataobjecttypename="Vendor"... /> <asp:objectdatasource id="inquiry"... dataobjecttypename="Inquiry" ... /> <asp:FormView datasourceid="vendor" ...> ... <asp:FormView datasourceid="inquiry" ...></asp:FormView> ... </asp:FormView>   Tony

View Complete Post

More Related Resource Links

CheckBoxList embedded in FormView InsertItemTemplate problem


I've searched hi/lo and found many similar posts but those answers aren't working for me.

I've got a FormView, in an UpdatePanel.  In the FormView's EditItemTemplate and InsertItemTemplate I'm using both a CheckBox and a CheckBoxList.  To present the data I databind in the code behind, (but then have to iterate to mark selected).  There I cast the sender as CheckBoxList in the OnPreRender event and use that object. 

The problem is retrieval.  I'm trying to access the user's entries when they submit by using the cast.  It is working fine for the CheckBox, but for the CheckBoxList the resulting checkboxlist object doesn't have any items. 

Here, both active and roles are created (they're not 'null') and active has the expected 'name' and 'selected' values, but roles has an item count = 0 and the for loop isn't entered.


            CheckBox active = ((CheckBox)Emp_Form.FindControl("cbActive"));

            CheckBoxList roles = (CheckBoxList)Emp_Form.FindControl("UsrRoles");

            foreach (ListItem role in roles.Items)
                // do stuff


Is there another way to cast a checkboxlist?  Any help would b

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  

Insert Parent and Child row in ONE Formview Dynamic Data


Hi All,

I am at my wits end and need some help, I have a dynamic data site, and have built a formview for my parent table, Claims (parent), Claims has a child table called DamagedVehicles, I want all the fields on the Cliams table and the fields on the DamagedVehicle to be displayed for insert on the same formsview, when the user fills in all data it should insert the claim and the damagedvehicle at the same time and set the foriegn key on the Damagedvehciles row to the Primary key of the claim, I dont know were to start any examples in VB.net or C# will be greatly appricated. i have been search for 3 days now trying to come to a solution and nothing has worked.

thanks in advance.

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?

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

Formview PagerTemplate DropDownList Navigation


Does anyone know if its possible to use a DropDownList within the PagerTemplate to navigate to a specific record?  I have been able to place the DropDownList outside of the FormView and PagerTemplate and make it work, however, I can't get it to work inside the PagerTemplate.


RadioButtonList in FormView EditTemplate's not me behind and OldValue NewValues


Hello people,

I am using FormView component which has a field that is the sex of the person that I am using RadioButtonList with a simple way to show Male and Female, but want to retrieve the information and OldValue NewValues not anything behind me.

In the FormView Edit Template:
" yc=""><! - SEX ->

Gender: " yc="Sexo:   " yc=""><td>
   'RepeatColumns = "2">     " yc="' RepeatColumns="2">"><Asp: RadioButtonList ID = "CHR_SEXORadioButtonList" runat = "server" SelectedValue ='<%# Eval ("CHR_SEXO")%> &#

Formview + EditItemTemplate + Bind + PageLoad + Prerender = Confused


I am working with a formview edititemtemplate.  Currently in my page load, i have some stuff that would show or hide certain panels based on dropdownlist values.  These dropdown values get binded during page load.  I need to be able to change the values/dropdowns, without rebinding the old data, and updating the visibility of the panels based on predefined rules.

I have experimented with putting my formview.databind() in page load if isnotpostback, in prerender, in prerender if isnotpostback.   I have tried my rules (ex if ddlState.selectedvalue = "DE" then pnlDelaware.visible = "true") in the page load, and the page render.   I'm just not sure how to get the stars aligned here.

The closest i have come is having the databind in the pageload if notispostback, and the rules in the prerender.   However I get an error "dropdownlist has a SelectedValue which is invalid because it does not exist in the list of items.


How do I show the last record added when using FormView?

hello all, I am using FormView to display one record at a time and after I add a new record, it won't display the last recorded added.How can I force FormView to display the last record added? Thank you  

Dealing with a databound DDL inside formview when SelectedValue no longer exists

Hi forum heros!  I have a page that has a formview on it.  Client info, name, address, usual stuff.  The formview is populated by a DataSource, that calls a SQL stored procedure for the client info.  It all works great. Within the formview, I have a dropdownlist for the Staff assigned to the client (StaffId is a member of the Client record called during the Formview binding).  When the formview is in Item mode, the Staff name appears in a label, when in Edit mode, the dropdownlist is bound and populated by another DataSource that calls a stored procedure of ActiveStaff. When the assigned staff exists, the StaffId is correctly bound to the DDL SelectedValue and the current staff name appears selected in the DDL when in edit mode, as it should. So here's the problem: Staff quit and become inactive.  So when the client record is pulled up, the StaffId (bound from the Formview) is no longer in the ActiveStaff list (used in the DDL) and the DropDownList bind fails (loudly - not sure why it couldn't just fail to zero, but there you go). Anyway, I know how to check for whether a record exists and manually bind dropdownlists that are outside formviews, but is it even possible within a formview? Any direction here would be appreciated. Thanks in advance.  

How to display multiline text in ECT formview?

Hello, with SPD i created External Content Type from MSSQL database. How to customize SharePoint:FormField in dispform.aspx to display multiline text from database? I tried use NoteField insted, but it trows excepion. BR  

formview insert help!!!

im using FORM VIEW Control for inserting , i want as i click on insert button of form view control it shows the just inserted data by form view in any GRID VIEW, FORM VIO
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