By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,727 Members | 1,263 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,727 IT Pros & Developers. It's quick & easy.

Err when creating link to each line of grid ..?

P: n/a
I am having err when creating link to each line of grid at LINE 38. My
objective in is: each line can be linked to page with your
parameters as VB 5/6, Delphi 5/6/7, etc....
See the code bellow:
Vilmar Brazão de Oliveira
HI-TEC Informática

<%@ Page Language="vb" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script language="VB" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Dim connString as String 'Create a connection string
connString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" &
'C:\Arquivos de programas\Microsoft Office\Office\Samples\Northwind.mdb

'Open a connection
Dim objConnection as OleDbConnection
objConnection = New OleDbConnection(connString)

'Specify the SQL string
Dim strSQL as String = "SELECT * FROM Clientes"

'Create a command object
Dim objCommand as OleDbCommand
objCommand = New OleDbCommand(strSQL, objConnection)

'Get a datareader
Dim objDataReader as OleDbDataReader
objDataReader = objCommand.ExecuteReader(CommandBehavior.CloseConn ection)

'Do the DataBinding
dgResults.DataSource = objDataReader

'Close the datareader/db connection

'Montagem de link.
Dim I as Double
Dim Registro as String

For I = 0 To Me.dgResults.Items.Count - 1
Dim NomeLink As LinkButton =
CType(datagrid.Items(i).FindControl("NomeLink"), LinkButton) 'LINE 38
Registro = Tabela.Rows(I)
lnkEdita.CommandArgument = "Param=" & valor
End Sub

Sub myItems_ItemDataBound(ByVal Sender As Object, ByVal e As
dgResults.Attributes.Add("onClick","javascript:ale rt('texto');")

If e.Item.ItemType = ListItemType.Item Then
ElseIf e.Item.ItemType = ListItemType.AlternatingItem Then
End If
End Sub

Protected Sub EventoNoClick(ByVal sender As Object, ByVal e As
Response.Redirect("SeuAspx.aspx?" & e.CommandArgument)
End Sub

'FFFFEF »»um tom de amarelo bem claro.
'F7EFC6 »»um tom de amarelo meio ocre.


<title>Exemplo consulta com ASP.Net - 02</title>

<body text="#000000" bgcolor="#ffffff">
<h1>Exemplo consulta com ASP.Net - 01</h1>

id="dgResults" runat="server" Width="700" BackColor="#F7EFC6"
ShowFooter="false" CellPadding="3" CellSpacing="0" Font-Name="Verdana"
HeaderStyle-BackColor="#ffaad" OnItemDataBound="myItems_ItemDataBound">

<asp:TemplateColumn HeaderText="Assunto">
<ItemStyle width="33%"></ItemStyle>
<asp:LinkButton id="NomeLink" runat="server" OnCommand="EventoNoClick"
Text='<%# DataBinder.Eval(DataSet, "Tables[Tabela].DefaultView.[0].Campo")

Nov 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.