Hi,
I try to add a new custome Module , I use SampleExternalModule as a tamplae.
in my module , I have a DropDownList that must bind to one Table on db and after selecting one Item and click Next , I show some other data...
But in first step , I can bind Data, but in Post back Dropdown is Clear and therefore , I can't find the selected Item.
What is wrong?
Thanks
Code Behind
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
// PopulateControls();
BindData();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = DropDownList1.SelectedItem.Text;
}
private void BindData()
{
Label1.Text = "bind";
this.DropDownList1.DataSource = TblIndGroup.FetchAll();
this.DropDownList1.DataTextField = TblIndGroup.Columns.Title;
this.DropDownList1.DataValueField = TblIndGroup.Columns.IndGroupCode;
this.DropDownList1.DataBind();
}
=====================
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="test1.ascx.cs" Inherits="mojoPortal.Web.Modules.test1" %>
<%@ Register TagPrefix="portal" Namespace="mojoPortal.Web" Assembly="mojoPortal.Web" %>
<%@ Register TagPrefix="portal" Namespace="mojoPortal.Web.UI" Assembly="mojoPortal.Web" %>
<%@ Register TagPrefix="mp" Namespace="mojoPortal.Web.Controls" Assembly="mojoPortal.Web.Controls" %>
<portal:ModuleTitleControl id="moduleTitle" runat="server" />
<asp:Panel ID="pnlSample" Runat="server">
<asp:DropDownList ID="DropDownList1" runat="server"
EnableViewState=true>
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</asp:Panel>
<div class="modulefooter"> </div>
UPDATE I find the solution here