Solved

Gridview - Row ---> Detailsview

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
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 …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 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

20 Experts available now in Live!

Get 1:1 Help Now