Record retrival
-
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...
-
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...
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
-
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
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
-
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
p=int.parse(session["abc"].ToString()); or p=convert.ToInt32(session["abc"].ToString()); Best Regards Pathan
GOD HELP THOSE WHO HELP THEMSELF
-
p=int.parse(session["abc"].ToString()); or p=convert.ToInt32(session["abc"].ToString()); Best Regards Pathan
GOD HELP THOSE WHO HELP THEMSELF
thanqs imran,,it's worked fine thanqs once again:-D