AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 Show one by one record from the FormView after click on Button in asp.net3.5
Posted by Asha Bhatt on  1/28/2010 2:28:16 AM Category: Asp.Net 2.0
Add to my favorites
Email to friend
Hi,
This is my code
<asp:FormView ID="QuestionList" runat="server" DataSourceID="SqlDataSource1"
AllowPaging="True" Visible="False"


>

<PagerSettings Mode="NextPrevious" />

<ItemTemplate>
<table style="width:100%;">
<tr>
<td class="style4">
<asp:Image ID="Image2" runat="server" ImageUrl="~/images/question.jpg" /></td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Question")%>
</td>
</tr>
<tr>
<td class="style4">
&nbsp;</td>
<td>
<asp:CheckBox ID="CheckBox9" runat="server" />
<%# DataBinder.Eval(Container.DataItem, "Option1")%>
</td>
</tr>
<tr>
<td class="style4"> &nbsp;</td>
<td>
<asp:CheckBox ID="CheckBox10" runat="server" />
<%# DataBinder.Eval(Container.DataItem, "Option2")%>
</td>
</tr>
<tr>
<td class="style4">&nbsp;</td>
<td>
<asp:CheckBox ID="CheckBox11" runat="server" />
<%# DataBinder.Eval(Container.DataItem, "Option3")%>
</td>
</tr>
<tr>
<td class="style4"> &nbsp;</td>
<td>
<asp:CheckBox ID="CheckBox12" runat="server" />
<%# DataBinder.Eval(Container.DataItem, "Option4")%>
</td>
</tr>
</table>
</ItemTemplate>
</asp:FormView>
<asp:Button ID="Button1" runat="server" Text=" Next " />
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:onlineexamdbConnectionString %>"
SelectCommand="SELECT [Question], [Option1], [Option2], [Option3], [Option4] FROM [QuestionData]">
</asp:SqlDataSource>

And this is my .aspx.cs code
using System.Diagnostics;
public partial class QuestionData : System.Web.UI.Page
{
string scon = "Data Source=RBWORKSTATION2\\SQLEXPRESS;Initial Catalog=onlineexamdb;Integrated Security=True;MultipleActiveResultSets=true";
SqlDataAdapter da;

DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlConnection con = new SqlConnection(scon);
da = new SqlDataAdapter("select Question,Option1,Option2,Option3,Option4 from QuestionData", con);
ds = new DataSet();
da.Fill(ds);
//QuestionList.Visible = true;
}

}
protected void Next_Click(object sender, EventArgs e)
{

}

I have table QuestionData which contain all question and option of each and every question .
so i have 5 column in this table.
now i want to show that when i will run the page then 1st question should be display then after click on next button 1time 2nd question will display ,after click on next button 2time 3nd question will displaydisplay , ans so on.
Please give me some help i m doing this last 4 day but not getting the out put .
Please Please Help me
Thank you.

Post Your Reply Post New Question

 Viewer's Reply
Use ViewState or Session to navigate
Answered By Moderator1 on 1/29/2010 8:19:12 PM
Hi,

I suggest you to use DataList, FormView is also fine, show 1 question at a time, then place a button "Next" at the page level. When page loads, you show question no. 1, use ViewState or Session to store the question sequence number(QSO). When User Clicks the next button, increase the QSO by 1, and re-load the page with next question and save the new QSO into your ViewState or Session. Thus you can move question by question.

No one can provide you complete code, but logic can. If you have any issues related this, post here below this answers.
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
The PHP Anthology: 101 Essential Tips, Tricks & Hacks, 2nd Edition - Free 207 Page Preview!
Programmers Heaven C# School Book - Free 338 Page eBook
FierceDeveloper