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
Serverside set value for Formview field syntax.
Sep 30 2013 1:29 PM
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
)
asp .net
Setting CB cntrl in FormV in FV1_DataBinding()