Dear Pals,

I have created a Datagrid on runtime , When I click on Next button Its working without 
an problem . But when I click on Prev Button its not working

Pls see the code given below

 

Public Class GeneralSearch

Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) 
Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

Dim objGetData As New clsCommonDML(Global.c1)

Dim DataGrid1 As New DataGrid()

Dim strColHeader As String

Dim strColName As String

Dim strTableName As String

Dim strCtrlName As String

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) 
Handles MyBase.Load

 

 

'Put user code to initialize the page here

strColHeader = Request.QueryString("ColHeader")

strColName = Request.QueryString("ColName")

strTableName = Request.QueryString("TabName")

strCtrlName = Trim(Request.QueryString("CtrlName"))

'Creates a Dynamic DataGrid at Runtime 

CreateGrid(strColHeader, strColName)

End Sub

Public Sub CreateGrid(ByVal strColHeader As String, ByVal strColName As String)

Dim arrColHeader() As String

Dim arrColName() As String

arrColHeader = strColHeader.Split(",")

arrColName = strColName.Split(",")

'Declare a New Datagrid And Set Properties

DataGrid1.BorderWidth = Unit.Pixel(2)

DataGrid1.CellPadding = 10

DataGrid1.GridLines = GridLines.Both

DataGrid1.BorderColor = Color.SaddleBrown

DataGrid1.BackColor = Color.AntiqueWhite

DataGrid1.ForeColor = Color.Black

DataGrid1.ShowHeader = True

DataGrid1.AutoGenerateColumns = False

DataGrid1.AllowPaging = True

DataGrid1.PageSize = 5

DataGrid1.PagerStyle.Mode = PagerMode.NextPrev

DataGrid1.PagerStyle.Position = PagerPosition.TopAndBottom

DataGrid1.PagerStyle.PrevPageText = "Prev"

DataGrid1.PagerStyle.NextPageText = "Next"

DataGrid1.SelectedItemStyle.BackColor = Color.BurlyWood

DataGrid1.DataKeyField = arrColName(0)

 

 

Dim dgTemplateCol As New TemplateColumn()

dgTemplateCol.HeaderText = "Project Account"

'Add bound columns to the datagrid

Dim datagridcol As New BoundColumn()

datagridcol.HeaderText = arrColHeader(0)

datagridcol.DataField = arrColName(0)

DataGrid1.Columns.Add(datagridcol)

Dim datagridcol1 As New BoundColumn()

datagridcol1.HeaderText = arrColHeader(1)

datagridcol1.DataField = arrColName(1)

DataGrid1.Columns.Add(datagridcol1)

Dim selectcol As New ButtonColumn()

selectcol.HeaderText = "Select"

selectcol.ButtonType = ButtonColumnType.LinkButton

selectcol.Text = "Select"

selectcol.CommandName = "Select"

DataGrid1.Columns.Add(selectcol)

'add event handlers

AddHandler DataGrid1.SelectedIndexChanged, AddressOf DataGrid1_SelectedIndexChanged

AddHandler DataGrid1.ItemDataBound, AddressOf DataGrid1_ItemDataBound

AddHandler DataGrid1.PageIndexChanged, AddressOf DataGrid1_Page

AddHandler DataGrid1.ItemCommand, AddressOf procSearch

BindData()

'add datagrid to the page

Page.Controls(1).Controls.Add(DataGrid1)

End Sub

Sub BindData()

Dim strQuery As String

Dim strIsDeleted As String

strIsDeleted = Mid(Trim(strTableName), 1, 3) & "_IsDeleted<>1"

strQuery = "Select " & strColName & " From " & strTableName & " Where " & strIsDeleted

' Response.Write(strQuery)

' Response.Write("<br>")

DataGrid1.DataSource = objGetData.getDetails(strQuery)

DataGrid1.DataBind()

End Sub

Public Sub DataGrid1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)

End Sub

Public Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As 
DataGridItemEventArgs)

End Sub

Sub DataGrid1_Page(ByVal sender As Object, ByVal e As DataGridPageChangedEventArgs)

Try

DataGrid1.CurrentPageIndex = e.NewPageIndex

BindData()

Catch objEX As Exception

'Response.Redirect("ErrorPage.aspx")

End Try

End Sub

Sub procSearch(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)

Dim strID, strName As String

Try

strID = Int32.Parse(e.Item.Cells(0).Text)

strName = e.Item.Cells(1).Text

e.Item.Attributes.Add("onclick", "CallParentSearch('" & strID & "','" & strName & 
"','" & strCtrlName & "');")

Catch objEX As Exception

'Response.Redirect("ErrorPage.aspx")

End Try

End Sub

End Class

 



Regards, 
R.Sundar 
Cell : 98401 94079 
Res : 91-44-26533061 / 22270593
  


                
---------------------------------
Do you Yahoo!?
vote.yahoo.com - Register online to vote today!

[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to