471,066 Members | 933 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 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 1369
jhardman
3,406 Expert 2GB
moved to .NET forum
Sep 20 '07 #2

Post your reply

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

Similar topics

1 post views Thread by Bob | last post: by
2 posts views Thread by Phil Sandler | last post: by

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.