Solved

Gridview - Row ---> Detailsview

Posted on 2006-12-01
1
2,247 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Cannot upload files above 1mb IIS7 11 39
Entity Framework 3 46
Tool Box 2 34
ASP.net Run 3 sliders vertically as opposed to horizontally 9 18
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

929 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now