473,404 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

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

Hi,
I am having err when creating link to each line of grid at LINE 38. My
objective in asp.net is: each line can be linked to page with your
parameters as VB 5/6, Delphi 5/6/7, etc....
See the code bellow:
Thanks!
---------------------------------------
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=" &
Server.MapPath("Northwind.mdb")
'C:\Arquivos de programas\Microsoft Office\Office\Samples\Northwind.mdb

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

'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
dgResults.DataBind()

'Close the datareader/db connection
objDataReader.Close()

'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
Next
End Sub

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

If e.Item.ItemType = ListItemType.Item Then
e.Item.Attributes.Add("onmouseover",
"this.style.backgroundColor='#EEEEEE'")
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='#F7EFC6'")
ElseIf e.Item.ItemType = ListItemType.AlternatingItem Then
e.Item.Attributes.Add("onmouseover",
"this.style.backgroundColor='#EEEEEE'")
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='#F7EFC6'")
End If
End Sub

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

'FFFFEF »»um tom de amarelo bem claro.
'F7EFC6 »»um tom de amarelo meio ocre.
</script>

<html>

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

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

<asp:DataGrid
id="dgResults" runat="server" Width="700" BackColor="#F7EFC6"
BorderColor="black"
ShowFooter="false" CellPadding="3" CellSpacing="0" Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#ffaad" OnItemDataBound="myItems_ItemDataBound">
</asp:DataGrid>

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

</body>
</html>
Nov 18 '05 #1
0 1227

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
2
by: Sherwood Botsford | last post by:
I'm new to access. I have an orienteering database that has information about locations all over the map. Each location has 0-N clues I've worked up a report that will print the locations,...
1
by: krian | last post by:
Hi, I need a help from anybody. My problem is here I wrote two WebApplication in ASP.net Using C#. The name of the applications are (Journal.aspx and Payment.aspx). These Two pages have DataGrids...
7
by: who be dat? | last post by:
I need some help here. I'm creating a list on a page where the list is created from a dataset with two tables linked with a datarelation. The first table is a list of groups while the second...
5
by: Richard Bysouth | last post by:
Hi I am trying to create an object that I can use to bind to a grid in my Win app. All of the examples that I have found on custom data sources have the properties (e.g. FirstNamer, LastName) of...
4
by: Bit byte | last post by:
I have a project that I normally build (without problems) from the DevStudio IDE. However, I have embarked on automating all my builds (this test project being one of several). The project...
3
by: kaczmar2 | last post by:
Hey there, I have a large image in a browser window, and I would like a way to overlay grid lines on top of the image, so a user can show the grid or hide the grid lines. The grid would cover...
1
by: --== Alain ==-- | last post by:
Hi, I finally found how to update the render of my custom control when one of its property value changed. However, i would like to know if there is not another way, because i'm afraid about...
1
by: djcronos | last post by:
Hi all, I'm using an open source template from oswd.org and I wanted to change the color of one of the links to make it stand out from the others. Here's the CSS code: .nav3-grid...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.