Hi,
Thanks for the reply.
it works it sends the correct u_id value to the next page via the querystring
but i have a problem when i want to go to the next page in my datagrid (i have paging).
when i press the link to the next page i get the following error:
Specified argument was out of the range of valid values. Parameter name: index
Source Error:
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)
ASPX:
asp:datagrid CssClass="GridWidth" id="DataGrid1" runat="server" HorizontalAlign="Right" AutoGenerateColumns="False"
BackColor="White" BorderWidth="2px" BorderStyle="Ridge" BorderColor="White" PagerStyle-HorizontalAlign="Center"
AllowPaging="True" OnPageIndexChanged="doPaging" CellPadding="3" Width="100%" Height="100%"
GridLines="None" CellSpacing="1">
<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#9471DE"></SelectedItemStyle>
<ItemStyle ForeColor="Black" BackColor="#DEDFDE"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#E7E7FF" BackColor="#4A3C8C"></HeaderStyle>
<FooterStyle ForeColor="Black" BackColor="#C6C3C6"></FooterStyle>
<Columns>
<asp:BoundColumn DataField="idnum" HeaderText="ú.æ."></asp:BoundColumn>
<asp:TemplateColumn HeaderText="ùà îìà ">
<ItemTemplate>
<a href ="<%#container.dataitem ("url_str")%>"><%#container.dataitem ("u_first")%> <%#container.dataitem ("u_last")%></a>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="u_password" HeaderText="ñéñîä"></asp:BoundColumn>
<asp:BoundColumn DataField="U_ID" HeaderText="ùà îùúîù"></asp:BoundColumn>
<asp:ButtonColumn Text="øùéîú îåãòåú" ButtonType="PushButton" DataTextFormatString="url_str" HeaderText="øùéîú îåãòåú" CommandName="ShowAll"></asp:ButtonColumn>
<asp:ButtonColumn Text="òãëï ôøèé îùúîù" ButtonType="PushButton" HeaderText="òãëï ôøèé îùúîù" CommandName="Update"></asp:ButtonColumn>
</Columns>
<PagerStyle HorizontalAlign="center" ForeColor="Black" BackColor="#C6C3C6" CssClass="Paging"
Mode="NumericPages"></PagerStyle>
I will appreciate the help.
Thanks