check box list item with a text box on check in share point list
-
I have a custom input form some of the fields are coming from a list in SharePoint 2010. I have a check box control which is populated by a list item. there are around 10 rows. Now i want when a user select a check box list item, a text box should appear beside it. for example I have a list called subjects, which have column name title and the entries are physics, maths, chem etc... Now when a user select physics from the check box list a text-box should appear beside it and user should be able to write on text box.
-
I have a custom input form some of the fields are coming from a list in SharePoint 2010. I have a check box control which is populated by a list item. there are around 10 rows. Now i want when a user select a check box list item, a text box should appear beside it. for example I have a list called subjects, which have column name title and the entries are physics, maths, chem etc... Now when a user select physics from the check box list a text-box should appear beside it and user should be able to write on text box.
Sounds liek you will want to have an event on the checkbo, where it will show or hide the textbox based on the checkbox being selected. What have you tried so far?
-
Sounds liek you will want to have an event on the checkbo, where it will show or hide the textbox based on the checkbox being selected. What have you tried so far?
protected void chkboxIncentive_SelectedIndexChanged(object sender, EventArgs e) { foreach (ListItem checkbox in chkboxIncentive.Items) { //If this particular item is checked if (checkbox.selected) { checkbox.Text = String.Format("{0}<input id=\"TextBox{0}\" name=\"TextBox{0}\" / >", checkbox.Value); //TextBox tb = new TextBox { ID = checkbox.Value }; //Input.Controls.Add(tb); } } } its throwing error at ListItem saying ambiguity and another error at selected and value
-
protected void chkboxIncentive_SelectedIndexChanged(object sender, EventArgs e) { foreach (ListItem checkbox in chkboxIncentive.Items) { //If this particular item is checked if (checkbox.selected) { checkbox.Text = String.Format("{0}<input id=\"TextBox{0}\" name=\"TextBox{0}\" / >", checkbox.Value); //TextBox tb = new TextBox { ID = checkbox.Value }; //Input.Controls.Add(tb); } } } its throwing error at ListItem saying ambiguity and another error at selected and value
checkbox.Text = String.Format("{0}<input id=\"TextBox{0}\" name=\"TextBox{0}\" / >", checkbox.Value);
This is going to cause you problems. You are on the right path with adding the textbox to the controls of the container tho, with:
//TextBox tb = new TextBox { ID = checkbox.Value };
//Input.Controls.Add(tb);Although I dont know what "Input" is, But I assume its a container for your controls. What are the exact errors you are getting? You could also create the text boxes when you create the checkboxes and then hide them by default, only showing when you need them?
-
checkbox.Text = String.Format("{0}<input id=\"TextBox{0}\" name=\"TextBox{0}\" / >", checkbox.Value);
This is going to cause you problems. You are on the right path with adding the textbox to the controls of the container tho, with:
//TextBox tb = new TextBox { ID = checkbox.Value };
//Input.Controls.Add(tb);Although I dont know what "Input" is, But I assume its a container for your controls. What are the exact errors you are getting? You could also create the text boxes when you create the checkboxes and then hide them by default, only showing when you need them?
I am getting error at foreach loop when i am using Listitem . the error says there is a ambiguity between system.data and microsoft.sharepoint
-
I am getting error at foreach loop when i am using Listitem . the error says there is a ambiguity between system.data and microsoft.sharepoint
OK, Now we are getting somewhere. It means, its cannot decide which 'ListItem' to use I would assume. Add the namespace infront of the class, Something like System.Data.ListItem - tho im not sure this is correct and I would use System.Web.UI.WebControls.ListItem but it all depends on what 'ListItem' class you are trying to use. -DB
-
OK, Now we are getting somewhere. It means, its cannot decide which 'ListItem' to use I would assume. Add the namespace infront of the class, Something like System.Data.ListItem - tho im not sure this is correct and I would use System.Web.UI.WebControls.ListItem but it all depends on what 'ListItem' class you are trying to use. -DB
I used Microsoft.SharePoint.Client.ListItem still I am getting error.