I need a link on a datagrid

L

Luis E Valencia

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

acciones.aspx?iddireccion=1&idindicador=4

Thanks
 
G

George Durzi

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>
 
L

Luis E Valencia

It didnt work
George Durzi said:
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>
 
G

George Durzi

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.
 
L

Luis E Valencia

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
 
G

George Durzi

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

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top