DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Thu, 9 Aug 2007 07:26:01 -0700,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    Peter
          2    Hardeep Kaur
          3    Hardeep Kaur
          4    David Wier


A DropDownList control updating Gridview Control   
Hi folks,
       A web form has a DropDownList control and GridView control. Both are 
data binding.  I expect that selecting an item in the DrowDownList will 
update the GridView visually. But, extra step is necessary by selecting  any 
item in the gridview, the gridview then refreshes. the related C# code as 
below:

 protected void DropDownList1_SelectedIndexChanged(...)
 {     VideoGridView.DataBind(); }      
Please advise. Thanks.
PeterK
Date:Thu, 9 Aug 2007 07:26:01 -0700   Author:  

Re: A DropDownList control updating Gridview Control   
Hopefully that would help you. i am working vb.net



Dim myConnection As New
SqlConnection(ConfigurationManager.ConnectionStrings("ResTrack").Connect
ionString)
        If Not IsPostBack Then
            Dim CmdPosition As SqlCommand = myConnection.CreateCommand()
            CmdPosition.CommandType = CommandType.Text
            CmdPosition.CommandText = "SELECT Position_ID,
Position_Title FROM position"
            Dim ds As DataSet = New DataSet
            Dim da As SqlDataAdapter = New SqlDataAdapter
            da.SelectCommand = CmdPosition
            da.Fill(ds, "position")
            With Position_Title
                .DataSource = ds.Tables("position")
                .DataTextField = "Position_Title"
                .DataValueField = "Position_ID"
                .DataBind()
            End With
        Else
            Dim CmdApplicants As SqlCommand = myConnection.CreateCommand
            CmdApplicants.CommandType = CommandType.Text
            CmdApplicants.CommandText = "Select * From Applicant"
            Dim daApplicant As New SqlDataAdapter
            Dim dsApplicant As New DataSet
            daApplicant.SelectCommand = CmdApplicants
            daApplicant.Fill(dsApplicant, "applicant")
            'create dataview
            Dim DV As New DataView(dsApplicant.Tables("applicant"))
            DV.RowFilter = "Position_ID = '" & _
       Position_Title.SelectedItem.Value & "'"
            View_Applicants.DataSource = DV
            View_Applicants.DataBind()
        End If
    End Sub


*** Sent via Developersdex http://www.developersdex.com ***
Date:Thu, 09 Aug 2007 08:06:56 -0700   Author:  

Re: A DropDownList control updating Gridview Control   
Dim myConnection As New
SqlConnection(ConfigurationManager.ConnectionStrings("ResTrack").Connect
ionString)
        If Not IsPostBack Then
            Dim CmdPosition As SqlCommand = myConnection.CreateCommand()
            CmdPosition.CommandType = CommandType.Text
            CmdPosition.CommandText = "SELECT Position_ID,
Position_Title FROM position"
            Dim ds As DataSet = New DataSet
            Dim da As SqlDataAdapter = New SqlDataAdapter
            da.SelectCommand = CmdPosition
            da.Fill(ds, "position")
            With Position_Title
                .DataSource = ds.Tables("position")
                .DataTextField = "Position_Title"
                .DataValueField = "Position_ID"
                .DataBind()
            End With
        Else
            Dim CmdApplicants As SqlCommand = myConnection.CreateCommand
            CmdApplicants.CommandType = CommandType.Text
            CmdApplicants.CommandText = "Select * From Applicant"
            Dim daApplicant As New SqlDataAdapter
            Dim dsApplicant As New DataSet
            daApplicant.SelectCommand = CmdApplicants
            daApplicant.Fill(dsApplicant, "applicant")
            'create dataview
            Dim DV As New DataView(dsApplicant.Tables("applicant"))
            DV.RowFilter = "Position_ID = '" & _
       Position_Title.SelectedItem.Value & "'"
            View_Applicants.DataSource = DV
            View_Applicants.DataBind()
        End If
    End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Date:Thu, 09 Aug 2007 08:07:11 -0700   Author:  

Re: A DropDownList control updating Gridview Control   
If you want the selected Item in the ddl to change the Gridview, your DDL 
must have the AutoPostback property set to 'True'

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no 
bloated markup

"Peter"  wrote in message 
news:E3CB2901-FD04-4B86-A62E-5C7C45877D80@microsoft.com...

> Hi folks,
>       A web form has a DropDownList control and GridView control. Both are
> data binding.  I expect that selecting an item in the DrowDownList will
> update the GridView visually. But, extra step is necessary by selecting 
> any
> item in the gridview, the gridview then refreshes. the related C# code as
> below:
>
> protected void DropDownList1_SelectedIndexChanged(...)
> {     VideoGridView.DataBind(); }
> Please advise. Thanks.
> PeterK 
Date:Thu, 9 Aug 2007 10:33:35 -0500   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us