I need a link on a datagrid

Discussion in 'ASP .Net' started by Luis E Valencia, May 28, 2004.

  1. I need a link on a datagrid, the link must have fields of the database
    Like this

    acciones.aspx?iddireccion=1&idindicador=4

    Thanks
     
    Luis E Valencia, May 28, 2004
    #1
    1. Advertising

  2. Luis E Valencia

    George Durzi Guest

    Search MSDN for info about the ASP:TemplateColumn

    <asp:TemplateColumn>
    <ItemTemplate>
    <asp:hyperlink runat="server" Text='Notes' NavigateUrl='<%#
    "contact_notes.aspx?id=" + DataBinder.Eval(Container, "DataItem.CLIENT_ID")
    %>'
    </asp:hyperlink>
    </ItemTemplate>
    </asp:TemplateColumn>

    "Luis E Valencia" <> wrote in message
    news:...
    > I need a link on a datagrid, the link must have fields of the database
    > Like this
    >
    > acciones.aspx?iddireccion=1&idindicador=4
    >
    > Thanks
    >
    >
     
    George Durzi, May 28, 2004
    #2
    1. Advertising

  3. It didnt work
    "George Durzi" <> escribió en el mensaje
    news:...
    > Search MSDN for info about the ASP:TemplateColumn
    >
    > <asp:TemplateColumn>
    > <ItemTemplate>
    > <asp:hyperlink runat="server" Text='Notes' NavigateUrl='<%#
    > "contact_notes.aspx?id=" + DataBinder.Eval(Container,

    "DataItem.CLIENT_ID")
    > %>'
    > </asp:hyperlink>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    >
    > "Luis E Valencia" <> wrote in message
    > news:...
    > > I need a link on a datagrid, the link must have fields of the database
    > > Like this
    > >
    > > acciones.aspx?iddireccion=1&idindicador=4
    > >
    > > Thanks
    > >
    > >

    >
    >
     
    Luis E Valencia, May 28, 2004
    #3
  4. Luis E Valencia

    George Durzi Guest

    Luis, you need to provide more details if you expect to get a detailed
    response to your question.

    What do you mean it didn't work? Why don't you post the HTML for your
    DataGrid and let us take a look at it.


    "Luis E Valencia" <> wrote in message
    news:...
    > It didnt work
    > "George Durzi" <> escribió en el mensaje
    > news:...
    > > Search MSDN for info about the ASP:TemplateColumn
    > >
    > > <asp:TemplateColumn>
    > > <ItemTemplate>
    > > <asp:hyperlink runat="server" Text='Notes'

    NavigateUrl='<%#
    > > "contact_notes.aspx?id=" + DataBinder.Eval(Container,

    > "DataItem.CLIENT_ID")
    > > %>'
    > > </asp:hyperlink>
    > > </ItemTemplate>
    > > </asp:TemplateColumn>
    > >
    > > "Luis E Valencia" <> wrote in message
    > > news:...
    > > > I need a link on a datagrid, the link must have fields of the database
    > > > Like this
    > > >
    > > > acciones.aspx?iddireccion=1&idindicador=4
    > > >
    > > > Thanks
    > > >
    > > >

    > >
    > >

    >
    >
     
    George Durzi, May 28, 2004
    #4
  5. This is the code of the datagrid

    <asp:datagrid id="dgmetas" runat="server" GridLines="Vertical"
    CellPadding="3" BackColor="White"
    BorderWidth="1px" BorderStyle="None" BorderColor="#999999"
    AutoGenerateColumns="False" DataKeyField="idindicador"
    Font-Size="X-Small" Font-Names="Trebuchet MS">
    <SelectedItemStyle Font-Bold="True" ForeColor="White"
    BackColor="#008A8C"></SelectedItemStyle>
    <AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle>
    <ItemStyle ForeColor="Black" BackColor="#EEEEEE"></ItemStyle>
    <HeaderStyle Font-Bold="True" ForeColor="White"
    BackColor="#000084"></HeaderStyle>
    <FooterStyle ForeColor="Black" BackColor="#CCCCCC"></FooterStyle>
    <Columns>
    <asp:TemplateColumn HeaderText="Nombre Indicador">
    <ItemTemplate>
    <asp:Label runat="server" Text='<%# DataBinder.Eval(Container,
    "DataItem.nombreIndicador") %>'>
    </asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox runat="server" Text='<%# DataBinder.Eval(Container,
    "DataItem.nombreIndicador") %>'>
    </asp:TextBox>
    </EditItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn>
    <ItemTemplate>
    <asp:LinkButton runat="server" Text="Ver"
    CommandName="editarMetas" CausesValidation="false"></asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn>
    <ItemTemplate>
    <asp:hyperlink runat="server" Text='Notes'
    NavigateUrl='<%acciones.aspx?iddireccion=" + DataBinder.Eval(Container,
    "DataItem.iddireccion") + " &idindicador= " + DataBinder.Eval(Container,
    "DataItem.idindicador")+"%>'
    </asp:hyperlink>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    <PagerStyle HorizontalAlign="Center" ForeColor="Black"
    BackColor="#999999" Mode="NumericPages"></PagerStyle>
    </asp:datagrid>


    and this is teh code that fills the datagrid


    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load

    'Introducir aquí el código de usuario para inicializar la página

    SqlConnection1.Open()

    If Not IsPostBack Then

    Dim selectCMD As SqlCommand = New SqlCommand("select * from tbldirecciones",
    SqlConnection1)

    selectCMD.CommandTimeout = 30

    Dim custDA As SqlDataAdapter = New SqlDataAdapter

    custDA.SelectCommand = selectCMD

    Dim custDS As DataSet = New DataSet

    custDA.Fill(custDS, "tbldirecciones")

    dgdir.DataSource = custDS.Tables("tbldirecciones").DefaultView

    If custDS.Tables("tbldirecciones").Rows.Count = 0 Then

    'errordir.Text = "NO hay direcciones en la base da datos, contacte al
    Administrador"

    Else

    dgdir.DataBind()

    End If

    End If

    End Sub


    "George Durzi" <> escribió en el mensaje
    news:...
    > Luis, you need to provide more details if you expect to get a detailed
    > response to your question.
    >
    > What do you mean it didn't work? Why don't you post the HTML for your
    > DataGrid and let us take a look at it.
    >
    >
    > "Luis E Valencia" <> wrote in message
    > news:...
    > > It didnt work
    > > "George Durzi" <> escribió en el mensaje
    > > news:...
    > > > Search MSDN for info about the ASP:TemplateColumn
    > > >
    > > > <asp:TemplateColumn>
    > > > <ItemTemplate>
    > > > <asp:hyperlink runat="server" Text='Notes'

    > NavigateUrl='<%#
    > > > "contact_notes.aspx?id=" + DataBinder.Eval(Container,

    > > "DataItem.CLIENT_ID")
    > > > %>'
    > > > </asp:hyperlink>
    > > > </ItemTemplate>
    > > > </asp:TemplateColumn>
    > > >
    > > > "Luis E Valencia" <> wrote in message
    > > > news:...
    > > > > I need a link on a datagrid, the link must have fields of the

    database
    > > > > Like this
    > > > >
    > > > > acciones.aspx?iddireccion=1&idindicador=4
    > > > >
    > > > > Thanks
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Luis E Valencia, May 28, 2004
    #5
  6. Luis E Valencia

    George Durzi Guest

    DataBinder.Eval is C# specific. You're using VB.NET. Lookup the equivalent
    in VB.NET

    "Luis E Valencia" <> wrote in message
    news:%...
    > This is the code of the datagrid
    >
    > <asp:datagrid id="dgmetas" runat="server" GridLines="Vertical"
    > CellPadding="3" BackColor="White"
    > BorderWidth="1px" BorderStyle="None" BorderColor="#999999"
    > AutoGenerateColumns="False" DataKeyField="idindicador"
    > Font-Size="X-Small" Font-Names="Trebuchet MS">
    > <SelectedItemStyle Font-Bold="True" ForeColor="White"
    > BackColor="#008A8C"></SelectedItemStyle>
    > <AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle>
    > <ItemStyle ForeColor="Black" BackColor="#EEEEEE"></ItemStyle>
    > <HeaderStyle Font-Bold="True" ForeColor="White"
    > BackColor="#000084"></HeaderStyle>
    > <FooterStyle ForeColor="Black" BackColor="#CCCCCC"></FooterStyle>
    > <Columns>
    > <asp:TemplateColumn HeaderText="Nombre Indicador">
    > <ItemTemplate>
    > <asp:Label runat="server" Text='<%# DataBinder.Eval(Container,
    > "DataItem.nombreIndicador") %>'>
    > </asp:Label>
    > </ItemTemplate>
    > <EditItemTemplate>
    > <asp:TextBox runat="server" Text='<%# DataBinder.Eval(Container,
    > "DataItem.nombreIndicador") %>'>
    > </asp:TextBox>
    > </EditItemTemplate>
    > </asp:TemplateColumn>
    > <asp:TemplateColumn>
    > <ItemTemplate>
    > <asp:LinkButton runat="server" Text="Ver"
    > CommandName="editarMetas" CausesValidation="false"></asp:LinkButton>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > <asp:TemplateColumn>
    > <ItemTemplate>
    > <asp:hyperlink runat="server" Text='Notes'
    > NavigateUrl='<%acciones.aspx?iddireccion=" + DataBinder.Eval(Container,
    > "DataItem.iddireccion") + " &idindicador= " + DataBinder.Eval(Container,
    > "DataItem.idindicador")+"%>'
    > </asp:hyperlink>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > </Columns>
    > <PagerStyle HorizontalAlign="Center" ForeColor="Black"
    > BackColor="#999999" Mode="NumericPages"></PagerStyle>
    > </asp:datagrid>
    >
    >
    > and this is teh code that fills the datagrid
    >
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    >
    > 'Introducir aquí el código de usuario para inicializar la página
    >
    > SqlConnection1.Open()
    >
    > If Not IsPostBack Then
    >
    > Dim selectCMD As SqlCommand = New SqlCommand("select * from

    tbldirecciones",
    > SqlConnection1)
    >
    > selectCMD.CommandTimeout = 30
    >
    > Dim custDA As SqlDataAdapter = New SqlDataAdapter
    >
    > custDA.SelectCommand = selectCMD
    >
    > Dim custDS As DataSet = New DataSet
    >
    > custDA.Fill(custDS, "tbldirecciones")
    >
    > dgdir.DataSource = custDS.Tables("tbldirecciones").DefaultView
    >
    > If custDS.Tables("tbldirecciones").Rows.Count = 0 Then
    >
    > 'errordir.Text = "NO hay direcciones en la base da datos, contacte al
    > Administrador"
    >
    > Else
    >
    > dgdir.DataBind()
    >
    > End If
    >
    > End If
    >
    > End Sub
    >
    >
    > "George Durzi" <> escribió en el mensaje
    > news:...
    > > Luis, you need to provide more details if you expect to get a detailed
    > > response to your question.
    > >
    > > What do you mean it didn't work? Why don't you post the HTML for your
    > > DataGrid and let us take a look at it.
    > >
    > >
    > > "Luis E Valencia" <> wrote in message
    > > news:...
    > > > It didnt work
    > > > "George Durzi" <> escribió en el mensaje
    > > > news:...
    > > > > Search MSDN for info about the ASP:TemplateColumn
    > > > >
    > > > > <asp:TemplateColumn>
    > > > > <ItemTemplate>
    > > > > <asp:hyperlink runat="server" Text='Notes'

    > > NavigateUrl='<%#
    > > > > "contact_notes.aspx?id=" + DataBinder.Eval(Container,
    > > > "DataItem.CLIENT_ID")
    > > > > %>'
    > > > > </asp:hyperlink>
    > > > > </ItemTemplate>
    > > > > </asp:TemplateColumn>
    > > > >
    > > > > "Luis E Valencia" <> wrote in message
    > > > > news:...
    > > > > > I need a link on a datagrid, the link must have fields of the

    > database
    > > > > > Like this
    > > > > >
    > > > > > acciones.aspx?iddireccion=1&idindicador=4
    > > > > >
    > > > > > Thanks
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    George Durzi, May 29, 2004
    #6
    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. Luis E Valencia

    I need help. build a link on a datagrid

    Luis E Valencia, May 27, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    341
    Luis E Valencia
    May 27, 2004
  2. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    882
    Kevin Spencer
    May 17, 2005
  3. Graham Thomson
    Replies:
    3
    Views:
    479
    Eki Y. Baskoro
    Dec 18, 2003
  4. Dan M
    Replies:
    5
    Views:
    435
  5. kolesdz
    Replies:
    9
    Views:
    543
    Blinky the Shark
    Aug 22, 2007
Loading...

Share This Page