Click here to Skip to main content
15,885,890 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionFile Upload Component...? Pin
Jassim Rahma28-Dec-12 9:44
Jassim Rahma28-Dec-12 9:44 
AnswerRe: File Upload Component...? Pin
Sandeep Mewara28-Dec-12 21:14
mveSandeep Mewara28-Dec-12 21:14 
QuestionCan we make a application to update FB status? Pin
anubhaw.gupta28-Dec-12 6:18
anubhaw.gupta28-Dec-12 6:18 
AnswerRe: Can we make a application to update FB status? Pin
Sandeep Mewara28-Dec-12 21:10
mveSandeep Mewara28-Dec-12 21:10 
QuestionLive Streaming Broadcasting Pin
AhmedYehiaK28-Dec-12 3:19
AhmedYehiaK28-Dec-12 3:19 
AnswerRe: Live Streaming Broadcasting Pin
Sandeep Mewara28-Dec-12 21:05
mveSandeep Mewara28-Dec-12 21:05 
GeneralRe: Live Streaming Broadcasting Pin
AhmedYehiaK29-Dec-12 0:03
AhmedYehiaK29-Dec-12 0:03 
QuestionHow to show the previous selected checked box in previous page in asp.net Pin
Arun kumar Gautam28-Dec-12 0:18
Arun kumar Gautam28-Dec-12 0:18 
I m making an online examination page on this page i created a gridview with paging when i go on next page thn aftr selecting options of answer of any question i m going on to another page. but when i come back on this previous page i cant see the previously selected answers the gridview page is refreshed thn, Please help me in it.
ASP.NET
<body>
    <div id="timer" style="float:right;">
    <label id="tim" style="font-size:15px;"></label>
    </div>
    <div>
    </body>
    <asp:ScriptManager ID="scrpt1" runat="server"></asp:ScriptManager>
    <asp:UpdatePanel ID="updt" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
    <asp:GridView ID="examgrid" runat="server" AllowPaging="true" 
            AutoGenerateColumns="false" onrowdatabound="examgrid_RowDataBound" 
            PageSize="2" onpageindexchanging="examgrid_PageIndexChanging" 
            PageIndex="10" Width="528px" EnableViewState="false" 
            onrowcommand="examgrid_RowCommand" 
            onpageindexchanged="examgrid_PageIndexChanged" onload="examgrid_Load">
    <Columns>
    <asp:TemplateField HeaderText="Question">
    <ItemTemplate>
    <asp:Label ID="ques" runat="server" Text='<%#Eval("Ques_Name") %>'></asp:Label>
    <asp:HiddenField ID="Question_Id" runat="server" Value='<%#Eval("Ques_Id") %>' /><br /><br />
    <asp:RadioButton ID="opt1" runat="server" GroupName="Radio" Text='<%#Eval("Option1") %>'/>
    <br />
    <asp:RadioButton ID="opt2" runat="server" GroupName="Radio" Text='<%#Eval("Option2") %>'/>
    <br />
    <asp:RadioButton ID="opt3" runat="server" GroupName="Radio" Text='<%#Eval("Option3") %>' />
    <br />
    <asp:RadioButton ID="opt4" runat="server" GroupName="Radio" Text='<%#Eval("Option4") %>'/>
    <br />
    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>
    </ContentTemplate>
    </asp:UpdatePanel>
    <asp:HiddenField ID="hidvalue" runat="server" EnableViewState="true" />
    <asp:Button ID="Submitbtn" runat="server" Text="Submit" style="float:right;" 
            onclick="Submitbtn_Click"/>
    </div>

and here is my c# code in gridview paging

C#
protected void examgrid_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        DBClass db = new DBClass();
      
        //hidvalue.Value = Convert.ToString(x);
        for (int i = 0; i < examgrid.Rows.Count; i++)
        {
            Label question = (Label)examgrid.Rows[i].Cells[0].FindControl("ques");
            HiddenField quesid = (HiddenField)examgrid.Rows[i].Cells[0].FindControl("Question_Id");
            RadioButton rd1 = (RadioButton)examgrid.Rows[i].Cells[0].FindControl("opt1");
            RadioButton rd2 = (RadioButton)examgrid.Rows[i].Cells[0].FindControl("opt2");
            RadioButton rd3 = (RadioButton)examgrid.Rows[i].Cells[0].FindControl("opt3");
            RadioButton rd4 = (RadioButton)examgrid.Rows[i].Cells[0].FindControl("opt4");
            string user = "Arun";
            if (rd1.Checked == true || rd2.Checked == true || rd3.Checked == true || rd4.Checked == true)
            {
                if (rd1.Checked == true)
                {
                    db.InsAnswer(user, question.Text, rd1.Text);
                    Session["selectedOption_"+quesid+"_Answer"]=rd1.Text;
                }
                else
                    if (rd2.Checked == true)
                    {
                        db.InsAnswer(user, question.Text, rd2.Text);
                        Session["selectedOption_"+quesid+"_Answer"]=rd2.Text;
                    }
                    else if (rd3.Checked == true)
                    {
                        db.InsAnswer(user, question.Text, rd3.Text);
                        Session["selectedOption_"+quesid+"_Answer"]=rd3.Text;
                    }
                    else if (rd4.Checked == true)
                    {
                        db.InsAnswer(user, question.Text, rd4.Text);
                        Session["selectedOption_"+quesid+"_Answer"]=rd4.Text;
                    }
                
            }
            else
            {
                for (int j = 0; j < examgrid.Rows.Count; j++)
                {
                    Label ques = (Label)examgrid.Rows[j].Cells[0].FindControl("ques");
                    int y = db.select_QuestionId(ques.Text);
                    string selected_option = db.Select_Ansqwer(question.Text, user);

                    if (Session["selectedOption_"+y+"_Answer"]==selected_option )
                    {
                        if (selected_option == rd1.Text)
                        {
                            rd1.Checked = true;
                        }
                        else if (selected_option == rd2.Text)
                        {
                            rd2.Checked = true;
                        }
                        else if (selected_option == rd3.Text)
                        {
                            rd3.Checked = true;
                        }
                        else if (selected_option == rd4.Text)
                        {
                            rd4.Checked = true;
                        }

                    }
                }
            }
        }
    }

AnswerRe: How to show the previous selected checked box in previous page in asp.net Pin
Sandeep Mewara28-Dec-12 21:17
mveSandeep Mewara28-Dec-12 21:17 
GeneralRe: How to show the previous selected checked box in previous page in asp.net Pin
Arun kumar Gautam29-Dec-12 1:16
Arun kumar Gautam29-Dec-12 1:16 
GeneralRe: How to show the previous selected checked box in previous page in asp.net Pin
anubhaw.gupta29-Dec-12 7:04
anubhaw.gupta29-Dec-12 7:04 
QuestionMicrosoft Sync Framework for File (Client) and SQL Server Database (Server) synchronization Pin
Ajeet mittal27-Dec-12 17:27
Ajeet mittal27-Dec-12 17:27 
QuestionWhat is the web.config for the <smtp> ? Pin
alihusain_7727-Dec-12 9:38
alihusain_7727-Dec-12 9:38 
AnswerRe: What is the web.config for the <smtp> ? Pin
Richard MacCutchan27-Dec-12 22:02
mveRichard MacCutchan27-Dec-12 22:02 
AnswerRe: What is the web.config for the <smtp> ? Pin
CommDev28-Dec-12 21:38
CommDev28-Dec-12 21:38 
QuestionImage album category wise Pin
Member 776731127-Dec-12 7:30
Member 776731127-Dec-12 7:30 
AnswerRe: Image album category wise Pin
Sandeep Mewara28-Dec-12 21:24
mveSandeep Mewara28-Dec-12 21:24 
QuestionCapsLock detection Pin
tpkpradeep27-Dec-12 0:04
tpkpradeep27-Dec-12 0:04 
AnswerRe: CapsLock detection Pin
AnalogNerd27-Dec-12 3:56
AnalogNerd27-Dec-12 3:56 
AnswerRe: CapsLock detection Pin
CommDev28-Dec-12 21:50
CommDev28-Dec-12 21:50 
QuestionApplication Layering Pin
Omersayeed26-Dec-12 2:31
Omersayeed26-Dec-12 2:31 
QuestionSyntax error in store procedure Pin
anubhaw.gupta25-Dec-12 22:06
anubhaw.gupta25-Dec-12 22:06 
AnswerRe: Syntax error in store procedure Pin
Sravanthid2825-Dec-12 22:21
Sravanthid2825-Dec-12 22:21 
GeneralRe: Syntax error in store procedure Pin
anubhaw.gupta25-Dec-12 22:40
anubhaw.gupta25-Dec-12 22:40 
AnswerRe: Syntax error in store procedure Pin
anubhaw.gupta25-Dec-12 22:45
anubhaw.gupta25-Dec-12 22:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.