passing a value to an event handler from dropdownlist

Discussion in 'ASP .Net Datagrid Control' started by DC Gringo, Mar 2, 2004.

  1. DC Gringo

    DC Gringo Guest

    I've got a command button to submit a value from a dropdown list that should
    then filter a SELECT query. I'm simply appending a WHERE colx =
    <variableSelectedFromDropdownList>. How do I pass this value into the event
    handler?

    -- MY EVENT HANDLER

    Sub RunReport_OnClick(sender As Object, e As System.EventArgs)

    _sqlStmt = _sqlStmt & " AND colx = '<variableSelectedFromDropdownList>'"
    BindData()


    End Sub

    -- ON MY WEB FORM
    <ASP:Button id="cmdRunReport" Text="Run Report" runat="server"
    onclick="RunReport_OnClick" />

    <ASP:dropdownlist id="Provinces" runat="server" Font-Size="8pt"
    Width="100px"></ASP:dropdownlist>


    -- MY DATA ACCESS CODE

    Sub BindData()
    Dim conString As String = "server=server;database=db;uid=un;pwd=pwd;"
    Dim myDataSet1 As New DataSet
    Dim myDataAdapter1 As New SqlDataAdapter(_sqlStmt, conString)
    myDataAdapter1.Fill(myDataSet1, "Communities")
    DataGrid2.DataSource = myDataSet1.Tables("Communities")

    Dim myDataSet2 As New DataSet
    Dim myDataAdapter2 As New SqlDataAdapter(_sqlStmt2, conString)
    myDataAdapter2.Fill(myDataSet2, "ProvincesT")
    Provinces.Datasource = myDataSet2.Tables("ProvincesT")
    Provinces.DataMember = "ProvincesT"
    Provinces.DataTextField = "clnName"
    Provinces.DataValueField = "clnGUID"


    DataGrid2.DataBind()
    Provinces.DataBind()

    End Sub


    _____
    DC G
     
    DC Gringo, Mar 2, 2004
    #1
    1. Advertising

  2. DC Gringo

    SB Guest

    Dear DC,

    Like this:

    Sub RunReport_OnClick(sender As Object, e As System.EventArgs)

    _sqlStmt = _sqlStmt & " AND colx = '"+this.Provinces.SelectedItem.Value+"'";
    BindData()

    Sélim


    "DC Gringo" <> wrote in message
    news:...
    > I've got a command button to submit a value from a dropdown list that

    should
    > then filter a SELECT query. I'm simply appending a WHERE colx =
    > <variableSelectedFromDropdownList>. How do I pass this value into the

    event
    > handler?
    >
    > -- MY EVENT HANDLER
    >
    > Sub RunReport_OnClick(sender As Object, e As System.EventArgs)
    >
    > _sqlStmt = _sqlStmt & " AND colx = '<variableSelectedFromDropdownList>'"
    > BindData()
    >
    >
    > End Sub
    >
    > -- ON MY WEB FORM
    > <ASP:Button id="cmdRunReport" Text="Run Report" runat="server"
    > onclick="RunReport_OnClick" />
    >
    > <ASP:dropdownlist id="Provinces" runat="server" Font-Size="8pt"
    > Width="100px"></ASP:dropdownlist>
    >
    >
    > -- MY DATA ACCESS CODE
    >
    > Sub BindData()
    > Dim conString As String = "server=server;database=db;uid=un;pwd=pwd;"
    > Dim myDataSet1 As New DataSet
    > Dim myDataAdapter1 As New SqlDataAdapter(_sqlStmt, conString)
    > myDataAdapter1.Fill(myDataSet1, "Communities")
    > DataGrid2.DataSource = myDataSet1.Tables("Communities")
    >
    > Dim myDataSet2 As New DataSet
    > Dim myDataAdapter2 As New SqlDataAdapter(_sqlStmt2, conString)
    > myDataAdapter2.Fill(myDataSet2, "ProvincesT")
    > Provinces.Datasource = myDataSet2.Tables("ProvincesT")
    > Provinces.DataMember = "ProvincesT"
    > Provinces.DataTextField = "clnName"
    > Provinces.DataValueField = "clnGUID"
    >
    >
    > DataGrid2.DataBind()
    > Provinces.DataBind()
    >
    > End Sub
    >
    >
    > _____
    > DC G
    >
    >
     
    SB, Mar 2, 2004
    #2
    1. Advertising

  3. DC Gringo

    DC Gringo Guest

    Thanks, SB for helping out...

    I think we're close...

    I did get a new error, though: "Name 'this' is not declared."


    ____
    DC G


    "SB" <> wrote in message
    news:%...
    > Dear DC,
    >
    > Like this:
    >
    > Sub RunReport_OnClick(sender As Object, e As System.EventArgs)
    >
    > _sqlStmt = _sqlStmt & " AND colx =

    '"+this.Provinces.SelectedItem.Value+"'";
    > BindData()
    >
    > Sélim
    >
    >
    > "DC Gringo" <> wrote in message
    > news:...
    > > I've got a command button to submit a value from a dropdown list that

    > should
    > > then filter a SELECT query. I'm simply appending a WHERE colx =
    > > <variableSelectedFromDropdownList>. How do I pass this value into the

    > event
    > > handler?
    > >
    > > -- MY EVENT HANDLER
    > >
    > > Sub RunReport_OnClick(sender As Object, e As System.EventArgs)
    > >
    > > _sqlStmt = _sqlStmt & " AND colx =

    '<variableSelectedFromDropdownList>'"
    > > BindData()
    > >
    > >
    > > End Sub
    > >
    > > -- ON MY WEB FORM
    > > <ASP:Button id="cmdRunReport" Text="Run Report" runat="server"
    > > onclick="RunReport_OnClick" />
    > >
    > > <ASP:dropdownlist id="Provinces" runat="server" Font-Size="8pt"
    > > Width="100px"></ASP:dropdownlist>
    > >
    > >
    > > -- MY DATA ACCESS CODE
    > >
    > > Sub BindData()
    > > Dim conString As String = "server=server;database=db;uid=un;pwd=pwd;"
    > > Dim myDataSet1 As New DataSet
    > > Dim myDataAdapter1 As New SqlDataAdapter(_sqlStmt, conString)
    > > myDataAdapter1.Fill(myDataSet1, "Communities")
    > > DataGrid2.DataSource = myDataSet1.Tables("Communities")
    > >
    > > Dim myDataSet2 As New DataSet
    > > Dim myDataAdapter2 As New SqlDataAdapter(_sqlStmt2, conString)
    > > myDataAdapter2.Fill(myDataSet2, "ProvincesT")
    > > Provinces.Datasource = myDataSet2.Tables("ProvincesT")
    > > Provinces.DataMember = "ProvincesT"
    > > Provinces.DataTextField = "clnName"
    > > Provinces.DataValueField = "clnGUID"
    > >
    > >
    > > DataGrid2.DataBind()
    > > Provinces.DataBind()
    > >
    > > End Sub
    > >
    > >
    > > _____
    > > DC G
    > >
    > >

    >
    >
     
    DC Gringo, Mar 2, 2004
    #3
  4. DC Gringo

    SB Guest

    Hello DC,

    Sorry, this is for C#, you must use Me.Provinces.... instead
    Selim
    "DC Gringo" <> wrote in message
    news:...
    > Thanks, SB for helping out...
    >
    > I think we're close...
    >
    > I did get a new error, though: "Name 'this' is not declared."
    >
    >
    > ____
    > DC G
    >
    >
    > "SB" <> wrote in message
    > news:%...
    > > Dear DC,
    > >
    > > Like this:
    > >
    > > Sub RunReport_OnClick(sender As Object, e As System.EventArgs)
    > >
    > > _sqlStmt = _sqlStmt & " AND colx =

    > '"+this.Provinces.SelectedItem.Value+"'";
    > > BindData()
    > >
    > > Sélim
    > >
    > >
    > > "DC Gringo" <> wrote in message
    > > news:...
    > > > I've got a command button to submit a value from a dropdown list that

    > > should
    > > > then filter a SELECT query. I'm simply appending a WHERE colx =
    > > > <variableSelectedFromDropdownList>. How do I pass this value into the

    > > event
    > > > handler?
    > > >
    > > > -- MY EVENT HANDLER
    > > >
    > > > Sub RunReport_OnClick(sender As Object, e As System.EventArgs)
    > > >
    > > > _sqlStmt = _sqlStmt & " AND colx =

    > '<variableSelectedFromDropdownList>'"
    > > > BindData()
    > > >
    > > >
    > > > End Sub
    > > >
    > > > -- ON MY WEB FORM
    > > > <ASP:Button id="cmdRunReport" Text="Run Report" runat="server"
    > > > onclick="RunReport_OnClick" />
    > > >
    > > > <ASP:dropdownlist id="Provinces" runat="server" Font-Size="8pt"
    > > > Width="100px"></ASP:dropdownlist>
    > > >
    > > >
    > > > -- MY DATA ACCESS CODE
    > > >
    > > > Sub BindData()
    > > > Dim conString As String =

    "server=server;database=db;uid=un;pwd=pwd;"
    > > > Dim myDataSet1 As New DataSet
    > > > Dim myDataAdapter1 As New SqlDataAdapter(_sqlStmt, conString)
    > > > myDataAdapter1.Fill(myDataSet1, "Communities")
    > > > DataGrid2.DataSource = myDataSet1.Tables("Communities")
    > > >
    > > > Dim myDataSet2 As New DataSet
    > > > Dim myDataAdapter2 As New SqlDataAdapter(_sqlStmt2, conString)
    > > > myDataAdapter2.Fill(myDataSet2, "ProvincesT")
    > > > Provinces.Datasource = myDataSet2.Tables("ProvincesT")
    > > > Provinces.DataMember = "ProvincesT"
    > > > Provinces.DataTextField = "clnName"
    > > > Provinces.DataValueField = "clnGUID"
    > > >
    > > >
    > > > DataGrid2.DataBind()
    > > > Provinces.DataBind()
    > > >
    > > > End Sub
    > > >
    > > >
    > > > _____
    > > > DC G
    > > >
    > > >

    > >
    > >

    >
    >
     
    SB, Mar 2, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DC Gringo
    Replies:
    5
    Views:
    504
    =?Utf-8?B?U3VyZXNo?=
    Mar 3, 2004
  2. Replies:
    0
    Views:
    677
  3. Replies:
    1
    Views:
    708
    Damien
    Feb 22, 2007
  4. Adi
    Replies:
    2
    Views:
    193
  5. Steve

    Passing a value to event handler

    Steve, Nov 4, 2007, in forum: Javascript
    Replies:
    11
    Views:
    161
    Thomas 'PointedEars' Lahn
    Nov 9, 2007
Loading...

Share This Page