| | |
Navigating records thru session variables
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2008
Posts: 38
Reputation:
Solved Threads: 0
Hi,
Im using ASP.NET as front end and SQL SERVER as backend. i navigate the records in this using session variables. but its not working.
After Inherits im writing
In Page_Load,
Im having 4 Textbox and 1 dropdownlist box in webform.
In DropDownList1 , doing all opeartions for database connection, and im writing the following text
I also Placed 4 buttons for NAvigation ,
In Button 1 - First
In Next Button,
But with this code it is not working , webpage remains same, not moving to next record.
And same for Previous also, it doesnt work.
For Previous Button im giving
For LAst Button,
So the Records i cant navigate, can any one help me solve this problem????????
(for the past 6 months im searching, but im not getting the correct solution.)
Im using ASP.NET as front end and SQL SERVER as backend. i navigate the records in this using session variables. but its not working.
asp.net Syntax (Toggle Plain Text)
Imports System Imports System.Data Imports System.Data.SqlClient
asp.net Syntax (Toggle Plain Text)
Dim con as SqlConnection Dim com as SqlCommand Dim adp as SqlDataAdapter Dim data as DataSet
In Page_Load,
asp.net Syntax (Toggle Plain Text)
con = New SqlConnection con.ConnectionString = "Data Source = ACER;Initial Catalog = Preethi;Inetgrated Security = True If Not IsPostBack() Then adp = New SqlDataAdapter("select * from emp",con) data = New DataSet adp.Fill(data) TextBox1.Text = data.Tables(0).Rows(0).Item(0) TextBox1.Text = data.Tables(0).Rows(0).Item(1) TextBox1.Text = data.Tables(0).Rows(0).Item(2) TextBox1.Text = data.Tables(0).Rows(0).Item(3) con.Open() Session("Recno") = 0 End If
Im having 4 Textbox and 1 dropdownlist box in webform.
In DropDownList1 , doing all opeartions for database connection, and im writing the following text
asp.net Syntax (Toggle Plain Text)
Session("Recno") = DropDownList1.SelectedValue. DropDowlList1.DataSource = data DropDownList1.DataTextField = "EmpName" DropDownList1.DataValueField = "EmpNo" DropDownList1.DataBind()
I also Placed 4 buttons for NAvigation ,
In Button 1 - First
asp.net Syntax (Toggle Plain Text)
Session("Recno") = 0 PreviousButton.Enabled = False
In Next Button,
asp.net Syntax (Toggle Plain Text)
Session("Recno") = +1 IF Session("Recno") = data.Tables(0).Rows.Count - 1 Then NextButton.Enabled = false MsgBox("Last Record")
And same for Previous also, it doesnt work.
For Previous Button im giving
Session("Recno") = -1 For LAst Button,
Session("Recno") = data.Tables(0).Rows.Count - 1 So the Records i cant navigate, can any one help me solve this problem????????
(for the past 6 months im searching, but im not getting the correct solution.)
Last edited by peter_budo; Sep 18th, 2008 at 1:07 pm. Reason: Keep It Organized - please use [code] tags as [code]YOUR CODE HERE[/code]
•
•
Join Date: Sep 2007
Posts: 68
Reputation:
Solved Threads: 13
Hi preety
You can use dataset's row postion to navigate.
Initial instance you can use
dim intRowno as integer
first button
Next button
Prev button
Last button
I hope this will help you.
Mohammed Yousuf uddin
Software Developer
You can use dataset's row postion to navigate.
Initial instance you can use
dim intRowno as integer
first button
ASP.NET Syntax (Toggle Plain Text)
Session("rowno") = "0" textbox1.text = Mydataset.tables(0).rows(0)("Columnname1").Tostring textbox2.text = Mydataset.tables(0).rows(0)("Columnname2").Tostring
Next button
ASP.NET Syntax (Toggle Plain Text)
intRowno = Session("rowno") + 1 textbox1.text = Mydataset.tables(0).rows(intRowno )("Columnname1").Tostring textbox2.text = Mydataset.tables(0).rows(intRowno )("Columnname2").Tostring Session("rowno") = intRowno
Prev button
ASP.NET Syntax (Toggle Plain Text)
intRowno =Session("rowno") textbox1.text = Mydataset.tables(0).rows(intRowno -1)("Columnname1").Tostring textbox2.text = Mydataset.tables(0).rows(intRowno -1)("Columnname2").Tostring
Last button
ASP.NET Syntax (Toggle Plain Text)
intRow= mydataset.rows.count-1 textbox1.text = Mydataset.tables(0).rows(mydataset.rows.count-1)("Columnname1").Tostring textbox2.text = Mydataset.tables(0).rows(mydataset.rows.count-1)("Columnname2").Tostring
I hope this will help you.
Mohammed Yousuf uddin
Software Developer
Last edited by peter_budo; Sep 18th, 2008 at 1:08 pm. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Jun 2008
Posts: 38
Reputation:
Solved Threads: 0
hi ,
I tried that. but still im getting error. actually im organizing the dataset from AddNewItem. so the dataset came like Dataset1. if i Add another dataset, then it will come like Dataset2.
So,
for the first time i gave in Page_load,
[ TextBox1.Text = Data.Tables(0).Rows(o)("ColumnName1").ToString ]
then it showed me,
" Table cannot found "
tthen i gave
[ TextBox1.Text = Data.Tables(1).Rows(0)("ColumnName1").ToString ]
then all data retrieved.
but in Next button
[ InitRecPos = session("recno") + 1 ]
[ TextBox1.Text = Data.Tables(1).Rows(InitRecPos)("ColumnName1").ToString ]
it shows
" Table 1 cannot found "
after that
i type
[ TextBox1.Text = Data.Tables(0).Rows(InitRecPos)("ColumnName1").ToString ]
Again it showed
" There is no row at position 1"
I tried that. but still im getting error. actually im organizing the dataset from AddNewItem. so the dataset came like Dataset1. if i Add another dataset, then it will come like Dataset2.
So,
for the first time i gave in Page_load,
[ TextBox1.Text = Data.Tables(0).Rows(o)("ColumnName1").ToString ]
then it showed me,
" Table cannot found "
tthen i gave
[ TextBox1.Text = Data.Tables(1).Rows(0)("ColumnName1").ToString ]
then all data retrieved.
but in Next button
[ InitRecPos = session("recno") + 1 ]
[ TextBox1.Text = Data.Tables(1).Rows(InitRecPos)("ColumnName1").ToString ]
it shows
" Table 1 cannot found "
after that
i type
[ TextBox1.Text = Data.Tables(0).Rows(InitRecPos)("ColumnName1").ToString ]
Again it showed
" There is no row at position 1"
![]() |
Other Threads in the ASP.NET Forum
- Previous Thread: Displaying Dialog Box in asp.net
- Next Thread: Horizontal and vertical centering of a Update panel progress bar in a page. How?
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn checkbox child click commonfunctions compatible confirmationcodegeneration content contenttype countryselector courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist dropdownmenu edit expose feedback flash flv form formatdecimal forms formview gridview homeedition iframe iis javascript jquery list listbox login menu microsoft mono mouse mssql multistepregistration nameisnotdeclared news numerical objects order panelmasterpagebuttoncontrols problem radio ratings rotatepage save schoolproject search security serializesmo.table silverlight smartcard sql-server sqlserver2005 suse textbox tracking typeof unauthorized validation vb.net video videos virtualdirectory vista visual-studio visualstudio web webarchitecture webdevelopemnt webservice xml youareanotmemberofthedebuggerusers





