472,960 Members | 1,885 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,960 software developers and data experts.

DropDownList is Empty on Insert Click of Formview

7
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
====================================

<asp:FormView id="FormViewEducation" runat="server" Width="100%" DataSourceID="EducationObjectContainerDataSource" DefaultMode="Insert" DataKeyNames="CollegeId">
<InsertItemTemplate>

<table width="100%">
<tr>
<td style="width:20%;"> Institute:
</td>
<td style="width:30%;">
<asp:DropDownList ID="CandidateEducationInstitute" runat="server" Width="100%">
</asp:DropDownList>
</td>

</tr>
</table>
</InsertItemTemplate>
</asp:FormView>

<asp:GridView ID="EducationGridView" runat="server" AutoGenerateColumns="False" AllowSorting="True" >
<Columns>
<asp:BoundField DataField="CollegeText" HeaderText="Institute" SortExpression="CollegeId" />
</Columns>
</asp:GridView>

===========================================

Here is the code Behind Page
========================================

private void ConfigureEducationDropDownLists()
{
DropDownList dropDownEducationInstitute = (DropDownList)this.FormView1.FindControl("Candidat eEducationInstitute");
dropDownEducationInstitute.DataSource = _catalogCollection[1].CatalogValueCollection;
dropDownEducationInstitute.DataMember = "CatalogValueCollection";
dropDownEducationInstitute.DataTextField = "Value";
dropDownEducationInstitute.DataValueField = "Id";
dropDownEducationInstitute.DataBind();
}

================================================== =

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
================================================== =========

protected void EducationObjectContainerDataSource_Inserted(object sender, Microsoft.Practices.Web.UI.WebControls.ObjectConta inerDataSourceStatusEventArgs e)
{
CandidateEducationProfileCollection educationValueCollection = (CandidateEducationProfileCollection)Session["educationValueCollection"];
DropDownList dropDownEducationInstitute = (DropDownList)this.FormView1.FindControl("FormView Education$CandidateEducationInstitute");
candidateEducation.CollegeId = int.Parse(dropDownEducationInstitute.SelectedValue .ToString());
educationValueCollection.Add(candidateEducation);
gridEducation.DataSource = educationValueCollection;
gridEducation.DataBind();
}
================================================== ===========

The two-way dataBinding is also not working , When is <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
1 1468
jhardman
3,406 Expert 2GB
moved to .NET forum
Sep 20 '07 #2

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

Similar topics

2
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
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
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
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
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
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"...
2
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
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
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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.