DIV, CheckBox

  • Thread starter Thread starter MS News
  • Start date Start date
M

MS News

Hello,

I am populating a DIV with Checkboxes based on rows I get from a Table
while dr.read()
.....
mydiv.controls.add(etc...)
.... other set up
end ...

On my webpage I check some of the check boxes then submit
on postsback how can I get back all the check boxes that were checked
it seems I can not get any thing back!!!
when I check mydiv.controls.count I get 0 (Zero)
what are ways to do that?

Any Ideas Please help

Thank you.
 
Hi,

do you recreate them on postback ?

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
 
Natty,

No I don't recreate them I tried it both ways and I can't get what the
client had to check them out
Thanks for any more help
 
OK,

try this, pay attention to the DIV style and the top, left, width and
height of the DataGrid
..

<div style="DISPLAY: block; Z-INDEX: 102; LEFT: 244px; OVERFLOW: auto;
WIDTH: 120px; POSITION: absolute; TOP: 145px; HEIGHT: 120px">
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 0px;
POSITION: absolute; TOP: 0px" runat="server" Height="100%" Width="100%">
<Columns>
<asp:HyperLinkColumn Text="a"
HeaderText="a"></asp:HyperLinkColumn>
<asp:ButtonColumn HeaderText="Add to cart" ButtonType="PushButton"
Text="Add" CommandName="AddToCart" />
</Columns>
</asp:DataGrid>
</div>

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
 
But where are you adding any controls dynamically and getting the result
back???????
this is my whole question
Do you have an example of adding few dynamic at runtime via programming few
checkboxes inside a DIV
then getting the result back without doing some javascript stuff??

Thank you
 
Sorry wrong post.

Here is the sample code that i want to send, by the way where do you
check the controls ?

// HTML
<div id="natty" name="natty" runat =server ></div>

// dynamic create of checkbox
private void Page_Load(object sender, System.EventArgs e)
{

for(int i = 0;i < 10 ; i ++)
{
CheckBox o = new CheckBox();
o.Visible = true;
o.ID = "myCheckBox" + i.ToString() ;
o.Text = "try" + i.ToString() ;
this.FindControl("natty").Controls.Add (o);
}
}

// check for control value on Button click

private void Button1_Click(object sender, System.EventArgs e)
{
bool x = ((CheckBox)this.FindControl("myCheckBox2")).Checked ;
}

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
 
Back
Top