Solved

Microsoft, Asp.Net, 2.0 - asp:FormView | EditItemTemplate |  asp:radiobuttonlist

Posted on 2008-10-15
2
282 Views
Last Modified: 2013-11-07
Dear Experts,
I have using an asp:FormView to capture data from end users.  Within this form I want the user to be able to edit a response if a mistake is made using 3 different asp:ListItems.  My problem is that when the user clicks on the form's edit button the edit portion of the asp:FormView does not capture the result that has already been stored in SQL Server.  So to the user, it looks like nothing was ever chosen.

How can I get the asp:RadioButtonList  to properly display the "selected" option that is stored in the database?  I'm new at codebehind and VB Scripting, so any example would be greatly appreciated.  I've read a lot about databinding options, but I don;t seem to grasp how to properly do it.

I am using a stored procedure to select all the necessary fields for the form.  This particular asp:RadioButtonList will be used for 15 different questions, each using the same 3 response options.  I should also mention that the field in the database is storing String values and not Boleen values.

Here's my code snippet:

<asp:Content>
<asp:FormView>
<EditItemTemplate>

<tr><td>
<asp:RadioButtonList ID="Sect1Fld1Opt1" runat="server" RepeatDirection="Horizontal">
         <asp:ListItem Text="N/A" Value="N/A" />
         <asp:ListItem Text="Complies" Value="Complies" />
         <asp:ListItem Text="Repairs Needed" Value="Repairs Needed" />
      </asp:RadioButtonList>
</td></tr>

</EditItemTemplate>
</asp:FormView>
</asp:Content>
0
Comment
Question by:Beallcorp
2 Comments
 
LVL 13

Accepted Solution

by:
crazyman earned 500 total points
ID: 22722517
Try adding this to the RadioButtonList

SelectedValue = '<%# Eval("YourFieldWithSelectedValueIn")%>'
0
 

Author Comment

by:Beallcorp
ID: 22722608
Excellent!  Thank you crazyman! I can't tell you how long I've been staring at this bugger.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now