Click here to Skip to main content
       

ASP.NET

 
QuestionFile Upload Component...? PinmemberJassim Rahma28-Dec-12 9:44 
AnswerRe: File Upload Component...? PinmvpSandeep Mewara28-Dec-12 21:14 
QuestionCan we make a application to update FB status? Pinmemberanubhaw.gupta28-Dec-12 6:18 
AnswerRe: Can we make a application to update FB status? PinmvpSandeep Mewara28-Dec-12 21:10 
QuestionLive Streaming Broadcasting PinmemberAhmedYehiaK28-Dec-12 3:19 
AnswerRe: Live Streaming Broadcasting PinmvpSandeep Mewara28-Dec-12 21:05 
GeneralRe: Live Streaming Broadcasting PinmemberAhmedYehiaK29-Dec-12 0:03 
QuestionHow to show the previous selected checked box in previous page in asp.net PinmemberArun 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.
<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") %>' />
 

    <asp:RadioButton ID="opt1" runat="server" GroupName="Radio" Text='<%#Eval("Option1") %>'/>
    
 
    <asp:RadioButton ID="opt2" runat="server" GroupName="Radio" Text='<%#Eval("Option2") %>'/>
    
 
    <asp:RadioButton ID="opt3" runat="server" GroupName="Radio" Text='<%#Eval("Option3") %>' />
    
 
    <asp:RadioButton ID="opt4" runat="server" GroupName="Radio" Text='<%#Eval("Option4") %>'/>
    
 
    </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
 
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 PinmvpSandeep Mewara28-Dec-12 21:17 
GeneralRe: How to show the previous selected checked box in previous page in asp.net PinmemberArun kumar Gautam29-Dec-12 1:16 
GeneralRe: How to show the previous selected checked box in previous page in asp.net Pinmemberanubhaw.gupta29-Dec-12 7:04 
QuestionMicrosoft Sync Framework for File (Client) and SQL Server Database (Server) synchronization PinmemberAjeet mittal27-Dec-12 17:27 
QuestionWhat is the web.config for the <smtp> ? Pinmemberalihusain_7727-Dec-12 9:38 
AnswerRe: What is the web.config for the <smtp> ? PinmvpRichard MacCutchan27-Dec-12 22:02 
AnswerRe: What is the web.config for the <smtp> ? [modified] PinmemberCommDev28-Dec-12 21:38 
QuestionImage album category wise PinmemberMember 776731127-Dec-12 7:30 
AnswerRe: Image album category wise PinmvpSandeep Mewara28-Dec-12 21:24 
QuestionCapsLock detection Pinmembertpkpradeep27-Dec-12 0:04 
AnswerRe: CapsLock detection PinmemberAnalogNerd27-Dec-12 3:56 
AnswerRe: CapsLock detection [modified] PinmemberCommDev28-Dec-12 21:50 
QuestionApplication Layering PinmemberOmersayeed26-Dec-12 2:31 
QuestionSyntax error in store procedure Pinmemberanubhaw.gupta25-Dec-12 22:06 
AnswerRe: Syntax error in store procedure PinmemberSravanthid2825-Dec-12 22:21 
GeneralRe: Syntax error in store procedure Pinmemberanubhaw.gupta25-Dec-12 22:40 
AnswerRe: Syntax error in store procedure Pinmemberanubhaw.gupta25-Dec-12 22:45 

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

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


Advertise | Privacy | Mobile
Web02 | 2.8.140821.2 | Last Updated 22 Aug 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid