Your issue is how are you going to Check an items in the CBL based on the Database Items.. So make that work first before doing anything else.. I mean disregard the Saving first... Once you make it work then you can proceed to your next issues..
yeah, im not sure WHY it isnt working for me. I added the same ListItems with the same values as you did for the checkboxlist
then got rid of the getMemberString() method, so now it should be getting hte values from teh listItems instead of the db.. then im using the following code as you suggested.
string
Members = dt.Rows[0]["AssignedMembers"].ToString();
string[] splitMembers = Members.Split(',');
//for (int i=0; i <cblMembersAssigned.Items.Count; i++)
for (int i=0; i < splitMembers.Length; i++)
//if it's equal then check the items in the CHeckBox
//cblMembersAssigned.Items[i].Selected = true;
string strItem = splitMembers[i].ToString();if (int.Parse(strItem)
== i)
SqlConnection conn =
new SqlConnection(Conn.CLNXCnnString());
conn.Open();
string sql = "select * from tblAddProject where ProjectName='" + strProjectName +
"'";
SqlCommand cmd =
new SqlCommand(sql, conn);
SqlDataAdapter da =
new SqlDataAdapter(cmd);DataTable dt =
new DataTable();
//Compare assigned members to database. check appropriate checkboxes
string Members = dt.Rows[0]["AssignedMembers"].ToString();
string[] splitMembers = Members.Split(',');
//for (int i=0; i <cblMembersAssigned.Items.Count; i++)
for (int i=0; i < splitMembers.Length; i++)
//if it's equal then check the items in the CHeckBox
//cblMembersAssigned.Items[i].Selected = true;
string strItem = splitMembers[i].ToString();if (int.Parse(strItem)
== i)
thats undestandable.. but the FindByValue doesnt work either..i step through the code in the breakpoints nad the values it showing are correct for the specified project.. dont have a clue why the checkboxes arent being checked..sorry for all of this and
i GREATLY appreciate your help and expertise, i have learned a tramendous amount from you in the last 2 days
vinz
All-Star
127087 Points
17946 Posts
MVP
Re: Populate fields from dropdown selection
Jun 24, 2008 06:58 PM|LINK
Your issue is how are you going to Check an items in the CBL based on the Database Items.. So make that work first before doing anything else.. I mean disregard the Saving first... Once you make it work then you can proceed to your next issues..
MessageBox Controls for WebForms | Blog | Twitter | Linkedin
kcrewjap
Member
15 Points
188 Posts
Re: Populate fields from dropdown selection
Jun 24, 2008 07:55 PM|LINK
okay.. removed the function.. tested it out and i can see the static checkboxes in the list, just none of them are actually being checked still
vinz
All-Star
127087 Points
17946 Posts
MVP
Re: Populate fields from dropdown selection
Jun 24, 2008 08:17 PM|LINK
I don't know what's happening in your codes but this snippet below works in my part
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
CheckBoxList1.Items.FindByText("2").Selected = true;
}
MessageBox Controls for WebForms | Blog | Twitter | Linkedin
kcrewjap
Member
15 Points
188 Posts
Re: Populate fields from dropdown selection
Jun 24, 2008 08:31 PM|LINK
yeah, im not sure WHY it isnt working for me. I added the same ListItems with the same values as you did for the checkboxlist
then got rid of the getMemberString() method, so now it should be getting hte values from teh listItems instead of the db.. then im using the following code as you suggested.
string
Members = dt.Rows[0]["AssignedMembers"].ToString(); string[] splitMembers = Members.Split(','); //for (int i=0; i <cblMembersAssigned.Items.Count; i++) for (int i=0; i < splitMembers.Length; i++){
//if (cblMembersAssigned.Items[i].Text == splitMembers[i].ToString()){
//if it's equal then check the items in the CHeckBox //cblMembersAssigned.Items[i].Selected = true; string strItem = splitMembers[i].ToString();if (int.Parse(strItem) == i){
cblMembersAssigned.Items.FindByText(strItem).Selected = true;}
}
}
do i need to zip up my project and email it to you?
kcrewjap
Member
15 Points
188 Posts
Re: Populate fields from dropdown selection
Jun 24, 2008 08:37 PM|LINK
in my selectedindexchanged i have the following:
protected void ddlSearch_SelectedIndexChanged(object sender, EventArgs e){
FillProjectFields(ddlSearch.SelectedValue);
}
the fill projectFields is below:
private void FillProjectFields(string strProjectName){
SqlConnection conn = new SqlConnection(Conn.CLNXCnnString());conn.Open();
string sql = "select * from tblAddProject where ProjectName='" + strProjectName + "'"; SqlCommand cmd = new SqlCommand(sql, conn); SqlDataAdapter da = new SqlDataAdapter(cmd);DataTable dt = new DataTable();da.Fill(dt);
if (dt.Rows.Count > 0){
txtDate.Text = dt.Rows[0][
"RequestDate"].ToString(); txtChangeUser.Text = dt.Rows[0]["NTLogin"].ToString();txtProjectName.Text = dt.Rows[0][
"ProjectName"].ToString(); txtProjectDesc.Text = dt.Rows[0]["ProjectDesc"].ToString();ddlOccurrence.Items.Add(dt.Rows[0][
"Occurrence"].ToString()); if(dt.Rows[0]["Occurrence"].ToString() == "Reoccurring"){
ddlOccurrence.SelectedValue = "Reoccurring";}
else if (dt.Rows[0]["Occurrence"].ToString() == "One Time"){
ddlOccurrence.SelectedValue = "One Time";}
rblOccurrance.Items.Add(dt.Rows[0]["Automated"].ToString());rblOccurrance.Items.Add(dt.Rows[0][
"Manual"].ToString()); ddlStatus.Items.Add(dt.Rows[0]["StatusName"].ToString());if (dt.Rows[0]["StatusName"].ToString() == "New"){
ddlStatus.SelectedValue = "New";}
else if (dt.Rows[0]["StatusName"].ToString() == "Assigned"){
ddlStatus.SelectedValue = "Assigned";}
else if (dt.Rows[0]["StatusName"].ToString() == "Complete"){
ddlStatus.SelectedValue = "Complete";}
//cblMembersAssigned.Items.Add(dt.Rows[0]["AssignedMembers"].ToString()); txtCompletionDate.Text = dt.Rows[0]["CompletionDate"].ToString();}
conn.Close();
//Compare assigned members to database. check appropriate checkboxes string Members = dt.Rows[0]["AssignedMembers"].ToString(); string[] splitMembers = Members.Split(','); //for (int i=0; i <cblMembersAssigned.Items.Count; i++) for (int i=0; i < splitMembers.Length; i++){
//if (cblMembersAssigned.Items[i].Text == splitMembers[i].ToString()){
//if it's equal then check the items in the CHeckBox //cblMembersAssigned.Items[i].Selected = true; string strItem = splitMembers[i].ToString();if (int.Parse(strItem) == i){
cblMembersAssigned.Items.FindByText(strItem).Selected = true;}
}
}
}
vinz
All-Star
127087 Points
17946 Posts
MVP
Re: Populate fields from dropdown selection
Jun 24, 2008 08:40 PM|LINK
You are still using FindByText in you codes.. Use FindByValue instead
cblMembersAssigned.Items.FindByValue(strItem).Selected = true;
MessageBox Controls for WebForms | Blog | Twitter | Linkedin
vinz
All-Star
127087 Points
17946 Posts
MVP
Re: Populate fields from dropdown selection
Jun 24, 2008 08:41 PM|LINK
I'm sorry but i wont entertain emails ..
MessageBox Controls for WebForms | Blog | Twitter | Linkedin
kcrewjap
Member
15 Points
188 Posts
Re: Populate fields from dropdown selection
Jun 24, 2008 08:49 PM|LINK
thats undestandable.. but the FindByValue doesnt work either..i step through the code in the breakpoints nad the values it showing are correct for the specified project.. dont have a clue why the checkboxes arent being checked..sorry for all of this and i GREATLY appreciate your help and expertise, i have learned a tramendous amount from you in the last 2 days
vinz
All-Star
127087 Points
17946 Posts
MVP
Re: Populate fields from dropdown selection
Jun 24, 2008 08:51 PM|LINK
Does it goes in this line below when you do the debugging ..
cblMembersAssigned.Items.FindByValue(strItem).Selected = true;
MessageBox Controls for WebForms | Blog | Twitter | Linkedin
kcrewjap
Member
15 Points
188 Posts
Re: Populate fields from dropdown selection
Jun 24, 2008 08:53 PM|LINK
yeah, when i hover over the (strItem) in that line, it shows the right value when im debugging