473,372 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

DropDownList 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
0 1189

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"...
1
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...
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...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.