473,396 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Run time error on page_load

I am fetching the question in DetailView. but in Page_Load its giving the runtime error "the Input String is not in a proper format. the code is as below.:

Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" Debug="true"%>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4.  
  5. <script runat="server"> 
  6.  
  7.     protected void Page_Load(object sender, EventArgs e)
  8.     {
  9.         DetailsView1.DataBind();        
  10.  
  11.     }
  12.  
  13.     protected void Button1_Click(object sender, EventArgs e)
  14.     {
  15.         //Save off previous answers
  16.         System.Data.DataRowView dr = (System.Data.DataRowView)DetailsView1.DataItem;
  17.  
  18.         // Create Answer object to save values
  19.         Answer a = new Answer();
  20.         a.QuestionID = dr["QuestionID"].ToString();
  21.         a.CorrectAnswer = dr["CorrectAnswer"].ToString();
  22.         a.UserAnswer = DropDownList1.SelectedValue.ToString();
  23.  
  24.         ArrayList al = (ArrayList)Session["AnswerList"];
  25.         al.Add(a);
  26.  
  27.         Session.Add("AnswerList", al);
  28.         if (DetailsView1.PageIndex == DetailsView1.PageCount - 1)
  29.         {
  30.             // Go to evaluate answers
  31.             Response.Redirect("evaluate.aspx");
  32.         }
  33.         else
  34.         {
  35.             DetailsView1.PageIndex++;
  36.             Button1.Text = "Finished";
  37.         }       
  38.     }
  39.  
  40. </script>
  41.  
Expand|Select|Wrap|Line Numbers
  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2. <head runat="server">
  3.     <title>Untitled Page</title>
  4. </head>
  5. <body>
  6.     <form id="form1" runat="server">
  7.     <div>    
  8.         <br />
  9.         <br />
  10.         <br />
  11.         <br />
  12.         <br />
  13.         <br />
  14.         <br />
  15.         <br />
  16. &nbsp;
  17.         <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
  18.             DataKeyNames="QuestionID" DataSourceID="SqlDataSource1" Height="50px" 
  19.             style="margin-left: 222px" Width="539px" ondatabinding="Page_Load">
  20.             <Fields>
  21.                 <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
  22.                 <asp:BoundField DataField="QuestionID" HeaderText="QuestionID" 
  23.                     InsertVisible="False" ReadOnly="True" SortExpression="QuestionID" />
  24.                 <asp:BoundField DataField="Answer1" HeaderText="Answer1" 
  25.                     SortExpression="Answer1" />
  26.                 <asp:BoundField DataField="Answer2" HeaderText="Answer2" 
  27.                     SortExpression="Answer2" />
  28.                 <asp:BoundField DataField="Answer3" HeaderText="Answer3" 
  29.                     SortExpression="Answer3" />
  30.                 <asp:BoundField DataField="Answer4" HeaderText="Answer4" 
  31.                     SortExpression="Answer4" />
  32.             </Fields>
  33.         </asp:DetailsView>
  34. &nbsp;
  35.         <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
  36.             ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
  37.             SelectCommand="SELECT [QuestionID], [Title], [Answer1], [Answer2], [Answer3], [Answer4], [CorrectAnswer] FROM [Question] WHERE ([QuizID] = @QuizID) ORDER BY [QuestionOrder]">
  38.             <SelectParameters>
  39.                 <asp:Parameter DefaultValue="@QuizID" Name="QuizID" Type="Int32" />
  40.             </SelectParameters>
  41.         </asp:SqlDataSource>
  42.         <br />
  43. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  44.         <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
  45. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  46.         <asp:DropDownList ID="DropDownList1" runat="server">
  47.             <asp:ListItem Value="1">A1</asp:ListItem>
  48.             <asp:ListItem Value="2">A2</asp:ListItem>
  49.             <asp:ListItem Value="3">A3</asp:ListItem>
  50.             <asp:ListItem Value="4">A4</asp:ListItem>
  51.         </asp:DropDownList>
  52. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  53.  <asp:RadioButton ID="RadioButton1" runat="server" Style="z-index: 103; left: 69px;
  54.             position: absolute; top: 157px" Text=" " />
  55.  
  56.     </div>
  57.     </form>
  58. </body>
  59. </html>
Oct 11 '11 #1
0 1230

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: NB | last post by:
Hi In my 2 years with Access I have never seen this, now it makes me mad In an unbound form frmTH I have a frmList which is a continous form In its on current event, I synch 4 of its fields...
0
by: Miranda Evans | last post by:
I noticed several postings about issues related to "run-time error 3061", and I observed that the solutions to these issues appear to involve correcting something within the SQL code. I'm...
0
by: crypto_solid via AccessMonster.com | last post by:
I have been using a SQL database with a VB5 frontend for about 5 years. Works well. Unfortunately I don't have access to the source code. I was tasked with implementing a "job entry" application...
2
by: dailem | last post by:
I have a bit of code tied to a command button in Access that runs a query then transfers it to a new Excel worksheet (& new file). It works fine EVERY OTHER TIME THAT I RUN IT....what the 'heck...
4
by: Christaaay | last post by:
I have been using the code below successfully for almost a year. yesterday, I began getting a run time error 6 (overflow). I am using the code in an Access 2000 database. Can anyone help me...
0
by: rc | last post by:
Moved a working MS Access application from Win2000 (version 5.0 SP 3) OS with MS Access 2000 and DB2 Run-time client v7.1 FP 4 to XP (version 5.1, SP 2) OS with MS Access 2003 and DB2 Run-time...
2
by: Greg Strong | last post by:
I'm experimenting with using Access 2k2 as a front end to Oracle Express. I am creating 10 tables using pass through DDL queries. The PROBLEM is the general format of the VB code WORKS on the 1st...
9
by: ThunderMusic | last post by:
Hi, I'd like to create a compile time error in my class... maybe there's a way already built in in the framework so I can achieve what I want... I have 2 constructors in my class. One of them...
3
by: DontB3 | last post by:
Hi, I'm new in this forum, and i hope someone can help. I'm creating an automatic application that transfer a database from Access -> DBF -> Oracle. When My App try to execute Insert SQL...
11
by: Bryan Crouse | last post by:
I am looking a way to do error checking on a string at compile time, and if the string isn't the correct length have then have the compiler throw an error. I am working an embedded software that...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.