TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
satish pawar
NA
9
17.1k
i cant access checkbox array variable on button click,object refrence error is occur
Jan 18 2010 8:00 AM
public CheckBox[] cb = null;
int z=0;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int count = (int)countcmd.ExecuteScalar();
Int32 k = Convert.ToInt32(Session["TZ"]);
cb = new CheckBox[count - k];
OleDbCommand cmd = new OleDbCommand("Select Member_Name from Member_Master", con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
//creating check box
cb[z] = new CheckBox();
cb[z].Text = dr["Member_Name"].ToString();
Panel2.Controls.Add(cb[z]);
Panel2.Controls.Add(new LiteralControl("</br>"));
// if (z == (t - 1)) { Button6.Visible = true; }
z = z + 1;
}
}
}
protected void Button6_Click(object sender, EventArgs e)
{
//proccess to get the value of checked box and insert into database
cb[tzx] = new CheckBox();
for (int x = 0; x < cb.Length; x++)//ERROR OOCUR HERE
{
//cb[x] = new CheckBox();
if (cb[x].Checked == true)
{
//remain code..
}
}
}
Reply
Answers (
0
)
Adding Command Promt manually in toolbox in VS 2008 express edition
How to prevent dynamically created controls from vanishing during postback ?