Datagrid ButtonColumn

collie

New member
Datagrid ButtonColumn

Hi, I have 2 problems with my dg and i hope someone can please advise: 1. My dg has paging but when i press the link to the next page i get the following error (if i don't press any page number then everything works fine): Specified argument was out of the range of valid values. Parameter name: index Source Error: Line 103: End Sub Line 104: Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand Line 105: Dim userCell As TableCell = e.Item.Cells(3) my aspx.vb code: 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 Dim isAuth As Boolean = False Try sid = Request.QueryString("sid") UD = (US.GetUserDataByGuid(sid)) Catch Response.Redirect("default.asp") End Try If Not UD.IsAdmin Then isAuth = False Response.Redirect("default.asp") End If End Sub Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click If txtSearch.Text = "" Then Response.Write("Enter text") Else fillTable() End If End Sub Sub fillTable() U_ID = txtSearch.Text cmd = oConn.CreateCommand cmd.CommandText = "SELECT *, 'UserMsg.aspx?sid=' + @sid +'&'+'U_ID=' + CAST(u_id AS NVARCHAR(16)) AS url_str, (SELECT TOP 1 ad_idnum FROM YBAY_MDB...ADS WHERE ad_poster=users.u_id) AS idnum FROM ybay_mdb...users USERS WHERE U_ID like '%'+@U_ID+'%'" cmd.Parameters.Add("@U_ID", U_ID) cmd.Parameters.Add("@sid", sid) Dim da As New SqlDataAdapter(cmd) Dim dt As New DataTable("ads") da.Fill(dt) DataGrid1.DataSource = dt DataGrid1.DataBind() End Sub Sub doPaging(ByVal s As Object, ByVal e As DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged DataGrid1.CurrentPageIndex = e.NewPageIndex fillTable() End Sub Private Sub btnMsg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMsg.Click Response.Redirect("edituser.aspx?sid=" & sid) End Sub Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand Dim userCell As TableCell = e.Item.Cells(3) Dim user As String = userCell.Text If e.CommandSource.commandname = "Update" Then Response.Redirect("editUser.aspx?u_id=" & user & "&sid=" & sid) End If 2.I want the paging to appear as follows: ....10,9,8,7,6,5,4,3,2,1 and not as it appears now which is: 1,2,3,4,5,6,7,8,9,10..... How can i do that? I tried dir=rtl and aligning the text but it doesn't work. I will appreciate the help. Thanks​
 
למעלה