buttonColumn

C

collie

Hi,

Can someone please help?

Currently I have in my datagrid a itemtemplate colume with a href
that is working.
However, instead of using itemTemplate i want to use a button but I
am not sure how to send the parameters sid &U_ID to the next page in a querystring when the button in the grid is clicked.

Here is my code so far:
aspx.vb
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
Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e
As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
DataGrid1.ItemCommand

If e.CommandSource.commandname = "Update" Then

Response.Redirect("../practice/databinding.aspx")

End If

If e.CommandSource.commandname = "ShowAll" Then

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

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="id"></asp:BoundColumn><asp:TemplateColumn HeaderText
="fullname"><ItemTemplate><a href ="<%#container.dataitem ("url_str")%>"><%#container.dataitem
("u_first")%><%#container.dataitem ("u_last")%></a>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top