C
CK
Hi All,
I have an asp:CheckBoxList. it is databound to a datatable at runtime;
private void chklstStatuses_DataBinding(object sender, EventArgs e)
{
chklstStatuses.DataSource = BillingInvoiceUtil.GetStatuses();
chklstStatuses.DataTextField = "StatusName";
chklstStatuses.DataValueField = "InvoiceStatusID";
}
I need to add an attribute to each list item,
"onClick=javascript:setFilter(this);"
I can not get it to work. I tried two different methods in two different
events, in chklstStatuses_DataBinding & in chklstStatuses_PreRender.
I try it like this
for(int x = 0; x != chklstStatuses.Items.Count; x++)
{
ListItem li = chklstStatuses.Items[x];
li.Attributes.Add("onClick","javascript:setFilter(this);");
}
doesn't work and I also tried
IEnumerator chklstEnumerator;
ListItem li;
chklstEnumerator = chklstStatuses.Items.GetEnumerator();
while(chklstEnumerator.MoveNext())
{
li = (ListItem)chklstEnumerator.Current;
li.Attributes.Add("onClick","javascript:setFilter(this);");
}
Neither one of these methods renders the attribute. I a compile fine and i
get no runtime or javascript errors in either case. I view the page source
and the attribute just doesn't seem to render.
Can anyone help?
Thanks,
~CK
I have an asp:CheckBoxList. it is databound to a datatable at runtime;
private void chklstStatuses_DataBinding(object sender, EventArgs e)
{
chklstStatuses.DataSource = BillingInvoiceUtil.GetStatuses();
chklstStatuses.DataTextField = "StatusName";
chklstStatuses.DataValueField = "InvoiceStatusID";
}
I need to add an attribute to each list item,
"onClick=javascript:setFilter(this);"
I can not get it to work. I tried two different methods in two different
events, in chklstStatuses_DataBinding & in chklstStatuses_PreRender.
I try it like this
for(int x = 0; x != chklstStatuses.Items.Count; x++)
{
ListItem li = chklstStatuses.Items[x];
li.Attributes.Add("onClick","javascript:setFilter(this);");
}
doesn't work and I also tried
IEnumerator chklstEnumerator;
ListItem li;
chklstEnumerator = chklstStatuses.Items.GetEnumerator();
while(chklstEnumerator.MoveNext())
{
li = (ListItem)chklstEnumerator.Current;
li.Attributes.Add("onClick","javascript:setFilter(this);");
}
Neither one of these methods renders the attribute. I a compile fine and i
get no runtime or javascript errors in either case. I view the page source
and the attribute just doesn't seem to render.
Can anyone help?
Thanks,
~CK