Solved

Gridview - Row ---> Detailsview

Posted on 2006-12-01
1
2,265 Views
Last Modified: 2012-05-05
When click Select on Gridview. I want the selected row to display on Detailsview on the same page. When I clicked Edit on Detailsview, I got this error "The Detailsview 'DetailsView1' fired event ModeChanging which wasn't handled."


Imports System.Data.SqlClient
Imports System.Data
Imports System.Web.Configuration

Partial Class Practice1
    Inherits System.Web.UI.Page

   
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


        Dim cnstr As String = WebConfigurationManager.ConnectionStrings("TEST").ConnectionString
        Dim cn As New SqlConnection(cnstr)
        Dim cmdstr As String = "select ID,TDATE, CITY, ZIPCODE STATE from residence"
        Dim ad As New SqlDataAdapter(cmdstr, cn)
        Dim ds As New DataSet

        ad.Fill(ds, "table1")
        Me.GridView1.DataSource = ds.Tables("table1")
        Me.GridView1.DataBind()



    End Sub


    Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand


        Dim index As Integer = Convert.ToInt32(e.CommandArgument)    
        Dim row As GridViewRow = Me.GridView1.Rows(index)
        Dim ID As String = row.Cells(1).Text

        Dim cnstr As String = WebConfigurationManager.ConnectionStrings("TEST").ConnectionString
        Dim cn As New SqlConnection(cnstr)
        Dim cmdstr As String = "select ID,TDATE, CITY, ZIPCODE STATE from residence where id =" & ID
        Dim ad As New SqlDataAdapter(cmdstr, cn)
        Dim ds As New DataSet

        ad.Fill(ds, "table1")

        Me.DetailsView1.DataSource = ds.Tables("table1")
        Me.DetailsView1.DataBind()



    End Sub

    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged

        DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)

    End Sub
0
Comment
Question by:VBdotnet2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 6

Accepted Solution

by:
DonKyles earned 500 total points
ID: 18059340
This is a good source for you. It has example and contains code in VB and C#.

http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/data/detailsview.aspx

This site will help you to fix the problem
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
asp web application 3 54
Problem to copy file 14 82
Access-Control-Allow-Origin 4 39
How does this modal work? 3 29
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question