I have a scenario of a user and departments, user had to select and save his departs at time of registration,
and then on update it maybe edit by him, so, the problem is that on the update page, I want to set checked = true on list of user departs, which is populating from the user_info db
(=> checked = true on those only which was selected by user previously at the time of registration)
maybe its clear question, but if any confusion, I will clear it,
Thanks for Helping me...
--------------------------------------------------------------------------------------------------
I have one solution but again the problem is that,I am calling that function on pageLoad but it will not work on load, but when I refresh my page it will work fine, (I am Checking Through Item Value, because, I was saved that in database, instead of depart Name)
try
{
sqlcon.Open();
cmd = new SqlCommand("select d.id from _dept d left join user u on u.id = d.id where u.email = '" + Email + "' order by d.id;", sqlcon);
reader = cmd.ExecuteReader();
while (reader.Read())
{
ListItem li = ChkStatus.Items.FindByValue(reader["id"].ToString());
if (li != null)
{
li.Selected = true;
}
}
}
catch (Exception)
{
MessageBox.Show("Found Error in Selecting your depart!");
Response.Redirect("user.aspx", false);
}
finally { sqlcon.Close(); }
User_Profile.aspx[
^]
user_profile.aspx.cs[
^]