HOW: Finding checkbox control with a datalist control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have images within a datalist control. Below is a checkbox control that
contains the SQL ID of the image blob.

When the page is post back I want to iterate though checkbox collection to
get the IDs

Normally you can say Request["myCheckbox"] and get all the values for those
items that were checked. I want to access the "chkDelete" collection so I can
enumerate though the the collection. How do I access the check boxes within
the datalist????????????

I tried (just to see if I get values) but Checkbox1 is always null:

System.Web.UI.HtmlControls.HtmlInputCheckBox Checkbox1 =
dataListControl.FindControl("chkDelete") as HtmlInputCheckBox;

Response.Write(Checkbox1.Value);
 
Hello JP,

Use HttpRequest.Form (see msdn for samples) collection with the name of you
control.

J> I have images within a datalist control. Below is a checkbox control
J> that contains the SQL ID of the image blob.
J>
J> When the page is post back I want to iterate though checkbox
J> collection to get the IDs
J>
J> Normally you can say Request["myCheckbox"] and get all the values for
J> those items that were checked. I want to access the "chkDelete"
J> collection so I can enumerate though the the collection. How do I
J> access the check boxes within the datalist????????????
J>
J> I tried (just to see if I get values) but Checkbox1 is always null:
J>
J> System.Web.UI.HtmlControls.HtmlInputCheckBox Checkbox1 =
J> dataListControl.FindControl("chkDelete") as HtmlInputCheckBox;
J>
J> Response.Write(Checkbox1.Value);
J>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 
Back
Top