Click here to Skip to main content
15,887,083 members
Home / Discussions / C#
   

C#

 
QuestionHow do I set variable in ShockwaveFlashObjects Pin
Member 106494598-Mar-14 5:07
Member 106494598-Mar-14 5:07 
AnswerRe: How do I set variable in ShockwaveFlashObjects Pin
Dave Kreskowiak8-Mar-14 5:10
mveDave Kreskowiak8-Mar-14 5:10 
GeneralRe: How do I set variable in ShockwaveFlashObjects Pin
Member 106494598-Mar-14 5:16
Member 106494598-Mar-14 5:16 
Question.net database connect api Pin
Jassim Rahma8-Mar-14 1:57
Jassim Rahma8-Mar-14 1:57 
AnswerRe: .net database connect api Pin
Dave Kreskowiak8-Mar-14 3:32
mveDave Kreskowiak8-Mar-14 3:32 
AnswerRe: .net database connect api Pin
Eddy Vluggen9-Mar-14 2:19
professionalEddy Vluggen9-Mar-14 2:19 
QuestionGet value from dynamic checkboxes Pin
NYCABR7-Mar-14 8:23
NYCABR7-Mar-14 8:23 
AnswerRe: Get value from dynamic checkboxes Pin
Richard Deeming7-Mar-14 9:07
mveRichard Deeming7-Mar-14 9:07 
First problem: you're re-binding the list on every load. This will clear the checked checkboxes. You need to wrap your binding code in an if (!IsPostBack) block:
C#
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        rptCandidats.DataSource = CUtil.GetResponses();
        rptCandidats.DataBind();
    }
}


Second problem: Your checkboxes don't have any values, and the Repeater control doesn't support the DataKey properties which would allow you to store arbitrary values against each item.

If you just want to return the value of the ResText field, it's fairly simple: bind the Text property of the CheckBox control to the ResText field, and return that. (This will also improve accessibility, since it will render a <label> for each CheckBox.)
ASP
<asp:Repeater id="rptCandidats" runat="server">
<ItemTemplate>
    <div>
        <asp:CheckBox id="chResponse" runat="server"
            Text='<%# Eval("ResText") %>'
        />
    </div>
</ItemTemplate>
</asp:Repeater>

C#
List<string> selectedItems = new List<string>(rptCandidats.Items.Count);
foreach (RepeaterItem item in rptCandidats.Items)
{
    CheckBox checkbox = (CheckBox)item.FindControl("chResponse");
    if (checkbox.Checked)
    {
        selectedItems.Add(checkbox.Text);
    }
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: Get value from dynamic checkboxes Pin
NYCABR10-Mar-14 3:38
NYCABR10-Mar-14 3:38 
QuestionInterface and abstract class why we use Pin
rahulmaurya1237-Mar-14 5:19
rahulmaurya1237-Mar-14 5:19 
AnswerRe: Interface and abstract class why we use Pin
Peter Leow7-Mar-14 5:29
professionalPeter Leow7-Mar-14 5:29 
AnswerRe: Interface and abstract class why we use Pin
Jason Gleim7-Mar-14 5:31
professionalJason Gleim7-Mar-14 5:31 
AnswerRe: Interface and abstract class why we use Pin
Eddy Vluggen7-Mar-14 7:17
professionalEddy Vluggen7-Mar-14 7:17 
AnswerRe: Interface and abstract class why we use Pin
jschell7-Mar-14 9:23
jschell7-Mar-14 9:23 
QuestionReading a filepath string from a table field and escapes are automatically added. Pin
Doncal7-Mar-14 4:52
Doncal7-Mar-14 4:52 
AnswerRe: Reading a filepath string from a table field and escapes are automatically added. Pin
Richard Deeming7-Mar-14 5:38
mveRichard Deeming7-Mar-14 5:38 
QuestionBank Transfer Form Pin
Cornille Michiel7-Mar-14 3:31
professionalCornille Michiel7-Mar-14 3:31 
Questionrefferences Pin
Mawande Ngoma7-Mar-14 2:38
Mawande Ngoma7-Mar-14 2:38 
AnswerRe: refferences Pin
Peter Leow7-Mar-14 3:05
professionalPeter Leow7-Mar-14 3:05 
Questiondatagridview: adding a combobox to a datagriedview dynamically at runtime , with a textbox as the last item. Pin
shrikanth_BG7-Mar-14 0:48
shrikanth_BG7-Mar-14 0:48 
AnswerRe: datagridview: adding a combobox to a datagriedview dynamically at runtime , with a textbox as the last item. Pin
Eddy Vluggen7-Mar-14 7:15
professionalEddy Vluggen7-Mar-14 7:15 
GeneralRe: datagridview: adding a combobox to a datagriedview dynamically at runtime , with a textbox as the last item. Pin
shrikanth_BG9-Mar-14 20:06
shrikanth_BG9-Mar-14 20:06 
Questionerror connection c# with oracle 11xe Pin
honar.cs6-Mar-14 21:28
honar.cs6-Mar-14 21:28 
AnswerRe: error connection c# with oracle 11xe Pin
Richard MacCutchan6-Mar-14 22:00
mveRichard MacCutchan6-Mar-14 22:00 
AnswerRe: error connection c# with oracle 11xe Pin
Pete O'Hanlon6-Mar-14 22:00
mvePete O'Hanlon6-Mar-14 22:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.