Hi! What is the best way to manually update some items in a formview using Entity Framework?
For example, I would like the user to select from a Checkbox list a few categories which the user will check the relavant ones. I would like to store those checked items as a comma seperated text in the database.
If I am using SQL DataSource, I could do something like this:
protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e)
{
CheckBoxList cboxlist = FormView1.FindControl("CheckBoxList1") as CheckBoxList;
if (cboxlist != null)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
foreach (ListItem item in cboxlist.Items)
{
if (item.Selected)
{
sb.AppendFormat("{0},", item.Value);
}
}
if (sb.Length > 0)
{
SqlDataSource1.UpdateParameters["category_csv"].DefaultValue = sb.ToString().TrimEnd(',');
}
}
}
However, there is no UpdateCommand in the EntityDataSource anymore, thus UpdatePArameter would not be of any use anymore..
What is the best way to do so?