Need to add aditional column to Datagrid

Discussion in 'ASP .Net Datagrid Control' started by Javier Villegas, Apr 28, 2004.

  1. Hi,

    I am new with VB.Net and I need some help

    I am building an ASP.Net application in where the user enter a letter and
    then press a button that make a SELECT in a SQL database. The results are
    displayed in a Datagrid

    This application is for look up phone numbers

    I made the SELECT from three fields (LASTNAME, FIRSTNAME and NUMBER), I need
    to add something like a hiperlink or a button in each row that make me
    possible press it and look for the picture of the phone´s owner.

    Is this possible ? Do you have an explample ?

    Thanks in advance

    I made this code:

    Private Sub bBuscar_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles bBuscar.Click
    Dim dReader2 As System.Data.SqlClient.SqlDataReader
    Dim Comandosql As System.String
    Comandosql = "Select LASTNAME,NAME,NUMBER from
    EMPLOYEE "
    SqlConnection1.Open()
    SqlCommand1.Connection = SqlConnection1
    If tApellido.Text <> "" Then Comandosql = Comandosql + "where
    LASTNAME like '" + tApellido.Text + "%' "
    If tApellido.Text <> "" And dFilial.SelectedValue <> "ALL" Then
    Comandosql = Comandosql + " and FILIAL = '" + dFilial.SelectedValue + "'"
    If tApellido.Text = "" And dFilial.SelectedValue <> "ALL" Then
    Comandosql = Comandosql + "where FILIAL = '" +
    dFilial.SelectedValue + "'"
    End If
    SqlCommand1.CommandText = Comandosql
    Label2.Text = SqlCommand1.CommandText
    dReader2 = SqlCommand1.ExecuteReader()
    DataGrid1.DataSource = dReader2
    DataGrid1.DataBind()
    dReader2.Close()
    SqlConnection1.Close()
    Comandosql = ""
    End Sub
     
    Javier Villegas, Apr 28, 2004
    #1
    1. Advertising

  2. http://www.c-sharpcorner.com/Code/2003/June/DataGridHyperLinkColumn.asp
    "Javier Villegas" <> wrote in message
    news:...
    > Hi,
    >
    > I am new with VB.Net and I need some help
    >
    > I am building an ASP.Net application in where the user enter a letter and
    > then press a button that make a SELECT in a SQL database. The results are
    > displayed in a Datagrid
    >
    > This application is for look up phone numbers
    >
    > I made the SELECT from three fields (LASTNAME, FIRSTNAME and NUMBER), I

    need
    > to add something like a hiperlink or a button in each row that make me
    > possible press it and look for the picture of the phone´s owner.
    >
    > Is this possible ? Do you have an explample ?
    >
    > Thanks in advance
    >
    > I made this code:
    >
    > Private Sub bBuscar_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles bBuscar.Click
    > Dim dReader2 As System.Data.SqlClient.SqlDataReader
    > Dim Comandosql As System.String
    > Comandosql = "Select LASTNAME,NAME,NUMBER from
    > EMPLOYEE "
    > SqlConnection1.Open()
    > SqlCommand1.Connection = SqlConnection1
    > If tApellido.Text <> "" Then Comandosql = Comandosql + "where
    > LASTNAME like '" + tApellido.Text + "%' "
    > If tApellido.Text <> "" And dFilial.SelectedValue <> "ALL" Then
    > Comandosql = Comandosql + " and FILIAL = '" + dFilial.SelectedValue + "'"
    > If tApellido.Text = "" And dFilial.SelectedValue <> "ALL" Then
    > Comandosql = Comandosql + "where FILIAL = '" +
    > dFilial.SelectedValue + "'"
    > End If
    > SqlCommand1.CommandText = Comandosql
    > Label2.Text = SqlCommand1.CommandText
    > dReader2 = SqlCommand1.ExecuteReader()
    > DataGrid1.DataSource = dReader2
    > DataGrid1.DataBind()
    > dReader2.Close()
    > SqlConnection1.Close()
    > Comandosql = ""
    > End Sub
    >
    >
    >
    >
    >
    >
     
    William Ryan eMVP, Apr 28, 2004
    #2
    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. Jim Hammond
    Replies:
    1
    Views:
    3,670
    bruce barker
    Nov 26, 2003
  2. Hai Nguyen
    Replies:
    0
    Views:
    412
    Hai Nguyen
    Jan 16, 2004
  3. Random
    Replies:
    1
    Views:
    4,702
    Random
    Nov 19, 2004
  4. Dexter
    Replies:
    1
    Views:
    432
    Eliyahu Goldin
    Jan 18, 2005
  5. John E.
    Replies:
    3
    Views:
    4,495
    masoud bayan
    Mar 25, 2005
Loading...

Share This Page