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
Shawn Austin
NA
7
6.8k
Setting CB cntrl in FormV in FV1_DataBinding()
Sep 30 2013 2:47 PM
So I thought I would list this question under a different subject. I am trying to set 5 different checkbox formview fields at runtime. I need help with the syntax.
I am trying to set a formview checkbox.checked on the server page using an if stmt to see what option was selected in a record from the sql db.
I am not getting the syntax right and I need some help. Below is the client code and the tenative server sided code. I am using VS 2012, c#, and asp.net 4.0/4.5.
This is the field in the formview that is set to the record field with the value.
<
asp
:
Label
ID
="lbloptionselc"
runat
="server"
Visible
="False"
Text
='
<%
#
Eval(
"RepaymentOptId"
) %>
'></
asp
:
Label
>
This is the server side page code for determining the checkbox to set to "Checked":
protected
void
FormView1_DataBinding(
object
sender,
EventArgs
e)
{
Label
lbloption =
new
Label
();
lbloption.Text =
this
.FormView1.FindControl(
"lbloptionselc"
).ToString();
string
formoption = lbloption.Text.ToString();
if
(formoption ==
"1"
)
{
CheckBox
cboption =
new
CheckBox
();
cboption.Checked =
true
;
this
.FormView1.FindControl(
"chkopt1"
)
?????????????
=
true
; ***************** WHAT IS THE CORRECT SYNTAX HERE ???
}
else
if
(formoption ==
"2"
)
{
}
else
if
(formoption ==
"3"
)
{
}
else
if
(formoption ==
"4"
)
{
}
else
if
(formoption ==
"5"
)
{
}
else
{
}
}
Reply
Answers (
0
)
Serverside set value for Formview field syntax.
Review a Book Function