Asp.net 2.0
LLBL 2.0.0.0
SQL 2000
Hello,
When I bind to the CheckBoxList in the ASPX page the checkbox DataValueField properly is properly set to the TaskID
<asp:CheckBoxList ID="CheckBoxList1" runat="server" DataTextField="Task" DataValueField="TaskId" OnSelectedIndexChanged="CheckBoxList1_SelectedIndexChanged" AutoPostBack="True" ></asp:CheckBoxList>
<llblgenpro:LLBLGenProDataSource id="LLBLGenProDataSource2" runat="server" DataContainerType="EntityCollection"
EntityCollectionTypeName="DAL.CollectionClasses.TaskCollection, App_Code._o46fjru">
</llblgenpro:LLBLGenProDataSource>
----- But when I try the same thing programatically and add a Ipredicate filter to the ----
protected void CheckListBox1_LoadData()
{
ArrayList alExistingTasks = GetExistingTasks(Request.QueryString["processID"]);
// get the task data
TaskCollection tc = new TaskCollection();
// create the filter
IPredicateExpression filter = new PredicateExpression();
// set filter excluding tasks that are already assigned to process
foreach (int x in alExistingTasks)
{
filter.Add(TaskFields.TaskId != x);
}
// apply filter
tc.GetMulti(filter);
// set the datasource
CheckBoxList1.DataSource = tc;
// bind data to control
CheckBoxList1.DataTextField = "Task";
CheckBoxList1.DataValueField = "TaskId";
CheckBoxList1.DataBind();
GridView1.DataSource = tc;
GridView1.DataBind();
}
The list populates and filters properly but CheckBoxList1_SelectedIndexChanged errors with "Input string was not in a correct format. "
protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
{
ProcessTaskEntity pt = new ProcessTaskEntity();
pt.ProcessId = Convert.ToInt32(Request.QueryString["processID"]);
pt.TaskId = Convert.ToInt32(CheckBoxList1.SelectedValue);
pt.Save();
}
When I write the value CheckBoxList1.SelectedValue it is null, but when the ASPX databinding is used it has the integer value...