Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Record retrival

Record retrival

Scheduled Pinned Locked Moved ASP.NET
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yuvachandra
    wrote on last edited by
    #1

    Hi friends,, am developeing a website to conduct certification exam for the buddys who are interested..some thing like a MCP,MCSD exam. to do this i have to design a webportal...where i have to expose a single qestion and answer each time...(let us say first time a exposed the first question)while clicking the next button i have to update the first question answer and expose the second one....to do this i did some manupulation like in page_load() { if (!IsPostBack==true) { da.Fill(ds, "dept"); p = 0; getrecord(p); } public void getrecord(int x) { //filling question and answers in the controls.. Label1.Text = ds.Tables["dept"].Rows[x].ItemArray[0].ToString(); RadioButton1.Text = ds.Tables["dept"].Rows[x].ItemArray[1].ToString(); RadioButton2.Text = ds.Tables["dept"].Rows[x].ItemArray[2].ToString(); RadioButton3.Text = ds.Tables["dept"].Rows[x].ItemArray[3].ToString(); RadioButton4.Text = ds.Tables["dept"].Rows[x].ItemArray[4].ToString(); } Nextbutton_click() { p++; getrecord(p); if (p == ds.Tables["dept"].Rows.Count - 1) { //some conformation } } But problem is while am working in windows application with thi code(omit !ispostback=true),it's working fine...while web application it's not.....i know every time the variable(p) is initializeing to position zero(0) though i used !ispostback(skipping page_load)event........! plz let me know the proper way to proceed ....or give some articles relateing to this scenario...thanqs in advance...

    N 1 Reply Last reply
    0
    • Y yuvachandra

      Hi friends,, am developeing a website to conduct certification exam for the buddys who are interested..some thing like a MCP,MCSD exam. to do this i have to design a webportal...where i have to expose a single qestion and answer each time...(let us say first time a exposed the first question)while clicking the next button i have to update the first question answer and expose the second one....to do this i did some manupulation like in page_load() { if (!IsPostBack==true) { da.Fill(ds, "dept"); p = 0; getrecord(p); } public void getrecord(int x) { //filling question and answers in the controls.. Label1.Text = ds.Tables["dept"].Rows[x].ItemArray[0].ToString(); RadioButton1.Text = ds.Tables["dept"].Rows[x].ItemArray[1].ToString(); RadioButton2.Text = ds.Tables["dept"].Rows[x].ItemArray[2].ToString(); RadioButton3.Text = ds.Tables["dept"].Rows[x].ItemArray[3].ToString(); RadioButton4.Text = ds.Tables["dept"].Rows[x].ItemArray[4].ToString(); } Nextbutton_click() { p++; getrecord(p); if (p == ds.Tables["dept"].Rows.Count - 1) { //some conformation } } But problem is while am working in windows application with thi code(omit !ispostback=true),it's working fine...while web application it's not.....i know every time the variable(p) is initializeing to position zero(0) though i used !ispostback(skipping page_load)event........! plz let me know the proper way to proceed ....or give some articles relateing to this scenario...thanqs in advance...

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      yuvachandra wrote:

      .i know every time the variable(p) is initializeing to position zero(0) though i used !ispostback(skipping page_load)event.

      It's not correct. Because not ispostback will execute only one time. But the variable p will reinitialize each time when postback occurs. That is not because you have assigned 0 for p inside not ispostback.

      yuvachandra wrote:

      plz let me know the proper way to proceed

      Have you ever heard about viewstates ? viewstates can help you on this problem. Viewstate is mechanism in ASP.NET which will add hidden fields in the page. So use like this.. in next button use p = viewstate["p"]; p++ viewstate["p"] = p; Will raise null reference exception if viewstate is not initialized before. So initialize it in ispostback method.

      Cheers Navaneeth!! www.w3hearts.com

      Y 1 Reply Last reply
      0
      • N N a v a n e e t h

        yuvachandra wrote:

        .i know every time the variable(p) is initializeing to position zero(0) though i used !ispostback(skipping page_load)event.

        It's not correct. Because not ispostback will execute only one time. But the variable p will reinitialize each time when postback occurs. That is not because you have assigned 0 for p inside not ispostback.

        yuvachandra wrote:

        plz let me know the proper way to proceed

        Have you ever heard about viewstates ? viewstates can help you on this problem. Viewstate is mechanism in ASP.NET which will add hidden fields in the page. So use like this.. in next button use p = viewstate["p"]; p++ viewstate["p"] = p; Will raise null reference exception if viewstate is not initialized before. So initialize it in ispostback method.

        Cheers Navaneeth!! www.w3hearts.com

        Y Offline
        Y Offline
        yuvachandra
        wrote on last edited by
        #3

        thanks for ur kind response..!, i do tried wih the code snippt u have given to me ....but it's raiseing some error like---Cannot implicitly convert type 'object' to 'int'. An explicit conversion exists (are you missing a cast?)... i did the same with session variables like... Nextbutton_click() { Session["abc"] = Session["abc"] + 1; p = int.Parse(Session["abc"]); getrecords(p); //i have declared session["abc"] =1 in the global.aspx aswell. } this time also i got the same error....PLz help me out... and

        I 1 Reply Last reply
        0
        • Y yuvachandra

          thanks for ur kind response..!, i do tried wih the code snippt u have given to me ....but it's raiseing some error like---Cannot implicitly convert type 'object' to 'int'. An explicit conversion exists (are you missing a cast?)... i did the same with session variables like... Nextbutton_click() { Session["abc"] = Session["abc"] + 1; p = int.Parse(Session["abc"]); getrecords(p); //i have declared session["abc"] =1 in the global.aspx aswell. } this time also i got the same error....PLz help me out... and

          I Offline
          I Offline
          Imran Khan Pathan
          wrote on last edited by
          #4

          p=int.parse(session["abc"].ToString()); or p=convert.ToInt32(session["abc"].ToString()); Best Regards Pathan

          GOD HELP THOSE WHO HELP THEMSELF

          Y 1 Reply Last reply
          0
          • I Imran Khan Pathan

            p=int.parse(session["abc"].ToString()); or p=convert.ToInt32(session["abc"].ToString()); Best Regards Pathan

            GOD HELP THOSE WHO HELP THEMSELF

            Y Offline
            Y Offline
            yuvachandra
            wrote on last edited by
            #5

            thanqs imran,,it's worked fine thanqs once again:-D

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups