Implementing a solution: A Set Of CheckBoxs and TextBox associated to each CheckBox
First of all I'm sorry for the question's title, but I've spent hours trying to figure out something for my problem and I really don't think the title can elaborate the idea tha开发者_C百科t I'm trying to implement so I hope I can deliver the idea here.
Ok, Now I have a page to create a bag .. each bag consists of items and quantity of each item should be specified.
CreateBagPage: I just need to have a set of CheckBoxs and a TextBox associated with each CheckBox.
the CheckBoxes Text property will be the name of the item (driven from my Db table) .. and if I want to add the item to the bag I select the checkbox .. I also have to specify a quantity for each item so that's why I need to associate a TextBox to each CheckBox. there's a little problem too, that made me start thinking about creating a UserControl and put it in a repeater. the problem is that each item has an ID and I need to I save the item through it's ID and there's no available properties in the CheckBox to accept sort of a ValueField or something!
I'm Hope I can find help here..
You can associate the hidden field, save the Id in that and then when you access the check and you can get the Id from hidden field
You could give your TextBoxes and CheckBoxes IDs with suffixes 1..n (like tb_1, cb_1) and when a checkBox is checked, parse the number x out of its ID and find the control with ID tb_x.
精彩评论