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
Chriz L
NA
220
50.8k
Create checkboxes dynamically
Dec 12 2016 7:35 AM
Hello,
I want to create dynamically checkboxes based on sproc result (one checkbox for each row).Here's my code:
public
void
selectChecks(Label appno, Label Cat)
{
SqlConnection connection = getConnection();
try
{
connection.Open();
SqlCommand command =
new
SqlCommand(
"ChecksSelect"
, connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(
"@Appno"
, SqlDbType.Int).Value = Convert.ToInt32(appno.Text);
command.Parameters.Add(
"@Cat"
, SqlDbType.Int).Value = Convert.ToInt32(Cat.Text);
SqlDataAdapter adapter =
new
SqlDataAdapter(command);
DataSet ds =
new
DataSet();
adapter.Fill(ds);
foreach
(DataTable table
in
ds.Tables)
{
foreach
(DataRow dr
in
table.Rows)
{
CheckBox check =
new
CheckBox();
check.Text = dr[
"CheckDescr"
].ToString();
if
(dr[
"CheckResult"
].ToString() ==
"1"
)
check.Checked =
true
;
else
check.Checked =
false
;
check.ID = dr[
"CheckCode"
].ToString() +
"Lbl"
;
}
}
}
catch
(Exception ex)
{ myMessageBox(ex.Message); }
}
How can I place them in my form's table?
Thank you in advance.
Reply
Answers (
6
)
data table to list
how to update db,when shutdown s\m without browser close app