C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

action event for dynamic checkbox control


Posted Date: 20 Sep 2008      Posted By: newtodev      Member Level: Silver     Points: 1   Responses: 1



I have created a list of dynamic checkbox and textbox corresponding to each checkbox.

The textboxes by default would be readonly mode.

On chkedchanged event the corresponsponding textbox shd get enabled.
The following is the piece of code.

for (int i = 1; i <= 2; i++)
{
objtableCell1 = new TableCell();
CheckBox chkbox = new CheckBox();
TextBox txtbox = new TextBox();
if (i == 1)
{
objtableCell1.HorizontalAlign = HorizontalAlign.Left;
objtableCell1.VerticalAlign = VerticalAlign.Top;
objtableCell1.Height = Unit.Pixel(10);
chkbox.ID = "chkbox" + j + i;

chkbox.Width = Unit.Pixel(400); chkbox.AutoPostBack = true; chkbox.CheckedChanged = callfunct(j) ; chkbox.Text = Convert.ToString(ds.Tables[0].Rows[j - 1]["disbursement"]); objtableCell1.Controls.Add(chkbox); objTableRow1.Cells.Add(objtableCell1);

objtableCell1 = new TableCell();
objTable1.Rows.Add(objTableRow1);

void callfunct(int l)
{


}

}
else if (i == 2)
{
objtableCell1.HorizontalAlign = HorizontalAlign.Left;
objtableCell1.VerticalAlign = VerticalAlign.Top;
objtableCell1.Height = Unit.Pixel(10);
txtbox.ID = "txtBox" + j + i;

txtbox.ID = "txtBox" + j + i; txtbox.Width = Unit.Pixel(100); txtbox.EnableViewState = true; txtbox.ReadOnly = true; objtableCell1.Controls.Add(txtbox); objTableRow1.Cells.Add(objtableCell1);



objtableCell1 = new TableCell();
objTable1.Rows.Add(objTableRow1);


}





Responses

Author: Elayaraja.K    22 Sep 2008Member Level: SilverRating: 2 out of 52 out of 5     Points: 1

you can add action event using this.
chkbox.Attributes.Add("click","fnc_Chkbox_click();")



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : TreeView Control
Previous : Email vaildation
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use