Click here to Skip to main content
15,894,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ASPX code:
XML
<td class="field1"><asp:CheckBox ID="CheckBox1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "PersonnelSummary_Cleveland_Resident") %>'/></td>
        <td class="field1"><asp:CheckBox ID="CheckBox2" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "PersonnelSummary_Present") %>' /></td>
<asp:Button ID="btnAddAnother" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Button") %>' CommandName='<%# DataBinder.Eval(Container.DataItem, "Button") %>' />

cs code:
C#
public void Rptr_ItemCommand(Object source, RepeaterCommandEventArgs e)
{
int Total = Rptr.items.Count;
if (e.CommandName == "Add")
{
Total = Total + 1; 
AddColumns();
foreach (Repeater item in Rptr.Items)
{
CheckBox PSR = ((CheckBox)item.FindControl("txtPSR"));
CheckBox PSP = ((CheckBox)item.FindControl("txtPSP"));
Button btnAdd = ((Button)item.FindControl("btnAddAnother"));
}
tb.Rows.Add(PSR,PSP, "Add");
}
else if (e.CommandName == "Remove")
   {
     Total = Total -1;
     CheckBox PSR = ((CheckBox)item.FindControl("txtPSR"));
     CheckBox PSP = ((CheckBox)item.FindControl("txtPSP"));
     Button btnAdd = ((Button)item.FindControl("btnAddAnother"));
   }
}

public void AddColumns()
{
 tb.Columns.Add("PSR", typeof(bool));
   tb.Columns.Add("PSP", typeof(bool));
   tb.Columns.Add("Button")
}

public void ButtonAdd_Click(object sender, EvenetArgs args)
{
AddColumns();
tb.Rows.Add(bool, bool, "Add");
btnAddAnother.Visible = false;
}

I have two problems:
P1: When a user click the add button, I get error on the check boxes. I change the bool to 1 or 0 it comes up true or false. When I click on the checkboxes to see if the change the answer is no.

P2: When the user click to remove it remove a dynamically created the very top
Posted
Updated 2-Sep-10 8:18am
v2
Comments
Sandeep Mewara 2-Sep-10 14:18pm    
Your problem2 sounds like incomplete. It's not clear.
postonoh 2-Sep-10 14:27pm    
Thanks

Problem two is fixed the remove button what not showing up on its current row.
koool.kabeer 4-Sep-10 6:16am    
just go through your code...
are you casting the CheckBoxes correctly?
on top you gave the Ids of CheckBoxes as "CheckBox1" and "CheckBox2" but you are finding with different key...as "txtPSR" and "txtPSP" ...
or there is any other thing which you didnt post?

1 solution

tb.Rows.Add(bool, bool, "Add");

This quite obviously won't work. Bool is a type not a value.
 
Share this answer
 
Comments
postonoh 2-Sep-10 14:30pm    
I know I change it to 0, 0 and the checkboxes come up false which mean unchecked. when I click the boxes to turn them true. They still read false
[no name] 2-Sep-10 20:21pm    
When are you data binding to the repeater?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900