﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Anything that is NOT about SQL! / SQLServerCentral.com  / VB.net error / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 23 May 2013 16:37:28 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: VB.net error</title><link>http://www.sqlservercentral.com/Forums/Topic1407760-61-1.aspx</link><description>[quote][b]mister.magoo (1/16/2013)[/b][hr][quote][b]pwalter83 (1/16/2013)[/b][hr][quote][b]mister.magoo (1/16/2013)[/b][hr]And do you actually have a component on the page called GridView1?[/quote]Thanks a lot for your help, I renamed the dropdownlist as GridView1 and it worked ![/quote]That's nice, but for your sake and others who follow you, I would change the drop down list name to something more meaningful and then modify the code to correctly reference the drop down list name...GridView1 isn't really a good name for a drop down list now is it? ;-)[/quote]Actually I have changed the name to a more meaningful now. Thanks again !</description><pubDate>Wed, 16 Jan 2013 07:59:28 GMT</pubDate><dc:creator>pwalter83</dc:creator></item><item><title>RE: VB.net error</title><link>http://www.sqlservercentral.com/Forums/Topic1407760-61-1.aspx</link><description>[quote][b]pwalter83 (1/16/2013)[/b][hr][quote][b]mister.magoo (1/16/2013)[/b][hr]And do you actually have a component on the page called GridView1?[/quote]Thanks a lot for your help, I renamed the dropdownlist as GridView1 and it worked ![/quote]That's nice, but for your sake and others who follow you, I would change the drop down list name to something more meaningful and then modify the code to correctly reference the drop down list name...GridView1 isn't really a good name for a drop down list now is it? ;-)</description><pubDate>Wed, 16 Jan 2013 05:41:18 GMT</pubDate><dc:creator>mister.magoo</dc:creator></item><item><title>RE: VB.net error</title><link>http://www.sqlservercentral.com/Forums/Topic1407760-61-1.aspx</link><description>[quote][b]mister.magoo (1/16/2013)[/b][hr]And do you actually have a component on the page called GridView1?[/quote]Thanks a lot for your help, I renamed the dropdownlist as GridView1 and it worked !</description><pubDate>Wed, 16 Jan 2013 05:36:13 GMT</pubDate><dc:creator>pwalter83</dc:creator></item><item><title>RE: VB.net error</title><link>http://www.sqlservercentral.com/Forums/Topic1407760-61-1.aspx</link><description>blank</description><pubDate>Wed, 16 Jan 2013 05:35:06 GMT</pubDate><dc:creator>pwalter83</dc:creator></item><item><title>RE: VB.net error</title><link>http://www.sqlservercentral.com/Forums/Topic1407760-61-1.aspx</link><description>It has been awhile since I've done any VB.net, but don't you need a WithEvents variable?e.g.[code="vb"]Dim WithEvents ev As New EventClassSub TestEvents()    ev.RaiseEvents()End SubSub ev_EventHandler() Handles ev.XEvent, ev.YEvent    MsgBox("Received Event.")End Sub[/code][hr][b]--EDIT--[/b][hr]Also, I take it you've had a look at the Microsoft tutorial?[code="vb"]&amp;lt;%@ Page language="VB" %&amp;gt;&amp;lt;script runat="server"&amp;gt;  Sub CustomersGridView_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)            ' Get the currently selected row using the SelectedRow property.    Dim row As GridViewRow = CustomersGridView.SelectedRow            ' Display the company name from the selected row.    ' In this example, the third column (index 2) contains    ' the company name.    Message.Text = "You selected " &amp; row.Cells(2).Text &amp; "."      End Sub  Sub CustomersGridView_SelectedIndexChanging(ByVal sender As Object, ByVal e As GridViewSelectEventArgs)            ' Get the currently selected row. Because the SelectedIndexChanging event    ' occurs before the select operation in the GridView control, the    ' SelectedRow property cannot be used. Instead, use the Rows collection    ' and the NewSelectedIndex property of the e argument passed to this     ' event handler.    Dim row As GridViewRow = CustomersGridView.Rows(e.NewSelectedIndex)    ' You can cancel the select operation by using the Cancel    ' property. For this example, if the user selects a customer with     ' the ID "ANATR", the select operation is canceled and an error message    ' is displayed.    If row.Cells(1).Text = "ANATR" Then       e.Cancel = True      Message.Text = "You cannot select " + row.Cells(2).Text &amp; "."          End If      End Sub&amp;lt;/script&amp;gt;&amp;lt;html&amp;gt;  &amp;lt;body&amp;gt;    &amp;lt;form runat="server"&amp;gt;             &amp;lt;h3&amp;gt;GridView Select Example&amp;lt;/h3&amp;gt;     &amp;lt;asp:gridview id="CustomersGridView"        datasourceid="CustomersSource"        autogeneratecolumns="true"       autogenerateselectbutton="true"       allowpaging="true"        selectedindex="0"       onselectedindexchanged="CustomersGridView_SelectedIndexChanged"       onselectedindexchanging="CustomersGridView_SelectedIndexChanging"          runat="server"&amp;gt;                       &amp;lt;selectedrowstyle backcolor="LightCyan"         forecolor="DarkBlue"         font-bold="true"/&amp;gt;                       &amp;lt;/asp:gridview&amp;gt;                  &amp;lt;br/&amp;gt;                  &amp;lt;asp:label id="Message"        forecolor="Red"        runat="server"/&amp;gt;                  &amp;lt;!-- This example uses Microsoft SQL Server and connects  --&amp;gt;      &amp;lt;!-- to the Northwind sample database. Use an ASP.NET     --&amp;gt;      &amp;lt;!-- expression to retrieve the connection string value   --&amp;gt;      &amp;lt;!-- from the Web.config file.                            --&amp;gt;      &amp;lt;asp:sqldatasource id="CustomersSource"        selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"        connectionstring="&amp;lt;%$ ConnectionStrings:NorthWindConnectionString%&amp;gt;"         runat="server"/&amp;gt;                &amp;lt;/form&amp;gt;  &amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;[/code]</description><pubDate>Wed, 16 Jan 2013 05:31:04 GMT</pubDate><dc:creator>Cadavre</dc:creator></item><item><title>RE: VB.net error</title><link>http://www.sqlservercentral.com/Forums/Topic1407760-61-1.aspx</link><description>And do you actually have a component on the page called GridView1?</description><pubDate>Wed, 16 Jan 2013 05:22:16 GMT</pubDate><dc:creator>mister.magoo</dc:creator></item><item><title>VB.net error</title><link>http://www.sqlservercentral.com/Forums/Topic1407760-61-1.aspx</link><description>Hi,I get this error when I build my code:"Handles clause requires a WithEvents variable defined in the containing type or one of its base types."Please find my code below (the error line is in bold):-------------------------------------	Public Class _Default    Inherits System.Web.UI.Page    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load    End Sub    Protected Sub GridView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles [b]GridView1[/b].SelectedIndexChanged    End SubEnd Class-------------------------------------Thanks,Paul</description><pubDate>Wed, 16 Jan 2013 05:09:06 GMT</pubDate><dc:creator>pwalter83</dc:creator></item></channel></rss>