Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Gridview - Row ---> Detailsview

Posted on 2006-12-01
1
Medium Priority
?
2,284 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 2000 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

636 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