473,491 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DropDownList is Empty on Insert Click of Formview

7 New Member
Hi all,

I have the DropDownList in the FormView,inside InsertTemplateField
The data is binded in run time to it in codebehind page,FOr the First time the page is loaded
the DropdownList is not empty.
when i click on the insert Link the data should be displayed in the gridView (Which is below the formview),
But when i click on the Insert link the data is displayed in the gridView,
But the DropdownList is empty.

Here is the Code Html
====================================
Expand|Select|Wrap|Line Numbers
  1.  <asp:FormView id="FormViewEducation"  runat="server" Width="100%" DataSourceID="EducationObjectContainerDataSource" DefaultMode="Insert" DataKeyNames="CollegeId">
  2.                               <InsertItemTemplate>
  3.  
  4.                                       <table width="100%">
  5.                                          <tr>
  6.                                             <td style="width:20%;"> Institute:
  7.                                             </td>
  8.                                             <td style="width:30%;">  
  9.                                                 <asp:DropDownList ID="CandidateEducationInstitute" runat="server" Width="100%">
  10.                                                 </asp:DropDownList>                                                
  11.                                             </td>
  12.  
  13.                                          </tr>
  14.                                       </table> 
  15.                               </InsertItemTemplate>                   
  16.                               </asp:FormView>
  17.  
  18.                               <asp:GridView ID="EducationGridView"  runat="server" AutoGenerateColumns="False" AllowSorting="True" >
  19.                                   <Columns>                                                                       
  20.                                       <asp:BoundField DataField="CollegeText" HeaderText="Institute" SortExpression="CollegeId" />
  21.                                   </Columns>
  22.                               </asp:GridView>
  23.  
===========================================

Here is the code Behind Page
========================================
Expand|Select|Wrap|Line Numbers
  1. private void ConfigureEducationDropDownLists()
  2.     {
  3. DropDownList dropDownEducationInstitute = (DropDownList)this.FormView1.FindControl("CandidateEducationInstitute");
  4.         dropDownEducationInstitute.DataSource = _catalogCollection[1].CatalogValueCollection;
  5.         dropDownEducationInstitute.DataMember = "CatalogValueCollection";
  6.         dropDownEducationInstitute.DataTextField = "Value";
  7.         dropDownEducationInstitute.DataValueField = "Id";
  8.         dropDownEducationInstitute.DataBind();
  9.    }
  10.  
================================================== =

I tried this funcation Calling inside ispostBack & outside the isPostback in the PageLoad
But still the data is empty on insert Link click.

Here is the code on the Insert Click of formView
================================================== =========
Expand|Select|Wrap|Line Numbers
  1. protected void EducationObjectContainerDataSource_Inserted(object sender, Microsoft.Practices.Web.UI.WebControls.ObjectContainerDataSourceStatusEventArgs e)
  2.     {
  3.     CandidateEducationProfileCollection educationValueCollection = (CandidateEducationProfileCollection)Session["educationValueCollection"];
  4.     DropDownList dropDownEducationInstitute =            (DropDownList)this.FormView1.FindControl("FormViewEducation$CandidateEducationInstitute");
  5.         candidateEducation.CollegeId = int.Parse(dropDownEducationInstitute.SelectedValue.ToString());
  6.         educationValueCollection.Add(candidateEducation);
  7.     gridEducation.DataSource = educationValueCollection;
  8.         gridEducation.DataBind();
  9.     }
================================================== ===========

The two-way dataBinding is also not working , When is
Expand|Select|Wrap|Line Numbers
  1. <asp:DropDownList ID="CandidateEducationInstitute" runat="server" Width="100%" selectedValue='<%# Bind("InstitueId")%>'>
I get the error
----------------------------

Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control



I am not getting were is the problem,

Thanks with Regards
Anil S
Sep 19 '07 #1
2 1321
pbmods
5,821 Recognized Expert Expert
Heya, Anil.

Please use CODE tags when posting source code:

[CODE]
Source code goes here.
[/CODE]

I'm going to go ahead and move this thread to the .NET forum, where our resident Experts will be better able to help you out.
Sep 19 '07 #2
Anilsg
7 New Member
Heya, Anil.

Please use CODE tags when posting source code:

Expand|Select|Wrap|Line Numbers
  1. Source code goes here.
  2.  
I'm going to go ahead and move this thread to the .NET forum, where our resident Experts will be better able to help you out.

Hi,
Thanks for the reply,
I will take care now Onwards.

Thanks with Regards
Anil S G
Sep 20 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
7882
by: Dabbler | last post by:
In my Registrant FormView I have a DropDownList which loads data from a secondary SqlDataSource "sdsOfficeParks". I need the user to select an office park but save the selected value in the...
1
2351
by: Bob | last post by:
I've made an upload function saving to a specific folder and dropdownlist reading and listing files from the folder. When I upload, the list is rendered a second time in the dropdownlist with the...
4
12898
by: J055 | last post by:
Hi I thought I was trying to do something very simple but I'm have a lot of trouble trying to do the following. <asp:FormView ID="fvGroups" runat="server" DataKeyNames="GroupID"...
0
1677
by: jobs at webdos | last post by:
I have a formview that will either edit or insert records into a database. when I call the page with a query string ?x= its goes to edit mode and loads data from a datasource in the form and load...
2
2323
by: Phil Sandler | last post by:
I am trying to do something which seems (to me) to be very simple, and yet I can't seem to figure it out. I have a gridview and a formview. When a user clicks "select" in the gridview, the...
0
1177
by: Jon Paal | last post by:
--dropdownlist value isn't being saved to database from FORMVIEW --field PriorityID is datatype "number" (integer) what's missing ???? '=========code============= <asp:Content ID="Content1"...
1
1503
by: Anilsg | last post by:
Hi all, I have the DropDownList in the FormView,inside InsertTemplateField The data is binded in run time to it in codebehind page,FOr the First time the page is loaded the DropdownList is...
0
1196
by: Anilsg | last post by:
Hi all, I have the DropDownList in the FormView,inside InsertTemplateField The data is binded in run time to it in codebehind page,FOr the First time the page is loaded the DropdownList...
1
4634
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
3464
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
0
7115
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7190
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7360
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.