buttonColumn

Discussion in 'ASP .Net Datagrid Control' started by collie, Jan 14, 2004.

  1. collie

    collie Guest

    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>
    collie, Jan 14, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Northern
    Replies:
    0
    Views:
    397
    Northern
    Jul 22, 2003
  2. CGuy
    Replies:
    2
    Views:
    1,998
  3. John
    Replies:
    3
    Views:
    3,233
    Giorgio Parmeggiani
    Nov 3, 2003
  4. Roger

    ButtonColumn

    Roger, Jan 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    539
    Ken Cox [Microsoft MVP]
    Jan 23, 2004
  5. =?Utf-8?B?Sm9obiBNY0RvbmFnaA==?=

    ButtonColumn postback problem

    =?Utf-8?B?Sm9obiBNY0RvbmFnaA==?=, Mar 6, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    387
    =?Utf-8?B?Sm9obiBNY0RvbmFnaA==?=
    Mar 6, 2004
Loading...

Share This Page