Suppose there is checkBox with id chkSelect and to perform ondatabinding event.How to do that?
+1
A:
You can add AutoPostBack="true"
and OnCheckedChanged="chkSelect_CheckChanged"
to your chkSelect CheckBox, then add this in your codebehind:
protected void chkSelect_CheckChanged(object sender, EventArgs e)
{
// your code here
}
if you want to perform actions when the CheckBox is checked/unchecked.
Or add OnDataBinding="chkSelect_DataBinding"
to your CheckBox and the following in your codebehind:
protected void chkSelect_DataBinding(object sender, EventArgs e)
{
// your code here
}
if you want to use the OnDataBinding event.
Brissles
2010-09-22 07:38:05
A:
I suppose you want to get ondatabinding event method called.
For this your check box should have event declared as:
<asp:CheckBox runat="server" ID="chkSelect" Text="CheckBox to bind" ondatabinding="chkSelect_DataBinding"/>
or
you can also do it Page_init or OnInit method as
protected override void OnInit(EventArgs e)
{
chkSelect.DataBinding += new EventHandler(chkSelect_DataBinding);
base.OnInit(e);
}
Now to let this event fire, you can call
chkSelect.DataBind(); in page_load. This will fire ondatabinding event.
SSA
2010-09-22 08:33:37
I cannot understand the code what you written above .Please explain the coding and function.
Shalni
2010-09-22 12:24:42
Well, in the code, if you don't want to set declarative ondatabinding in aspx page then you can also do it in code behind so its assignment of event handler to event DataBinding and when you call chkSelect.DataBind(), it will trigger the event ondatabinding. you can also set declarative ondatabinding="chkSelect_DataBinding", thats no problem, but call chkSelect.DataBind() to trigger it.
SSA
2010-09-22 12:47:50