Problem CheckBox

A

Adam

Hi
Have have problems with CheckBoxs
because when a click on the CheckBox, rb.Text.Trim() write to me
results as how many exist CheckBoxs, but I want only one result
But when I click next CheckBox, the rb.Text.Trim() should be add to
result

public void DetayGoster(object sender,EventArgs e)

{
//txtSiraNo.Text="1";
CheckBox rb = new CheckBox();
rb = (CheckBox) sender;
sRbText = rb.ClientID;

foreach (DataGridItem di in DataGrid1.Items)

{
// rb = (CheckBox) i.FindControl ("rbsira");
// rb.Checked = false;
//if (sRbText==rb.ClientID)
//{
// rb.Checked = true;
if (rb.Checked )
{
txtSiraNo.Text += rb.Text.Trim();
}
// if you want to get a property of the selected id
//}
}
}
</script>

<body>
<form runat="server">
<asp:DataGrid runat="server" id="DataGrid1"
BorderColor="black"
BorderWidth="2"
CellPadding="2"
AutoGenerateColumns="false"
style="font-family:arial;font-size:10pt"
runat="server">
<HeaderStyle BackColor="#000099" forecolor="#ECEBE8" />
<Columns>
<asp:TemplateColumn HeaderText="Login">
<ItemTemplate>
<asp:CheckBox id="rbsira"
allowselectall="True" SelectionMode="Multiple" AutoPostBack=true
OnCheckedChanged="DetayGoster"
runat="server" cssclass="StdText" Text='<%#
DataBinder.Eval(Container.DataItem, "FirstName") %>' />

</ItemTemplate>

</asp:TemplateColumn>
<asp:BoundColumn DataField="EmployeeId"
HeaderText="Tytul" SortExpression="title, EmployeeId" />
<asp:BoundColumn DataField="firstname"
HeaderText="Ilość zleceń" SortExpression="title,
EmployeeId" />
</Columns>

</asp:DataGrid>
<asp:label id=txtSiraNo forecolor= "#000000"
runat="Server"></asp:label>

</form>
</body>
</html>

Help me, please
 
C

Cor Ligthert

Adam,

Than why don't you do in the event

if ((TextBox) sender.Checked) ................

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top