Note that there are some explanatory texts on larger screens.

plurals
  1. POAccess Control value in static or shared Method in asp.net
    primarykey
    data
    text
    <p>let say you have static method in which you want to access the dropdownlist selected value textbox value and some other controls value.. my problem is that i am always getting first selected value of dropdownlist even whatever value i select in dropdown</p> <p>what i did i create a property of dropdownlist then get a value in page_Load event then pass this value into static method</p> <pre><code> Partial Public Class stocklist Inherits System.Web.UI.Page 'Static or shared Property' Private Shared _make As DropDownList Public Shared Property MAKE() As DropDownList Get Return _make End Get Set(ByVal value As DropDownList) _make = value End Set End Property 'Page Load' Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'ddlMake is the dropdownlist and MAKE is a Property' MAKE = ddlMake End Sub 'Static or shared Web Method' &lt;WebMethod()&gt; _ Public Shared Function Select_Search() As SearchParameters() Dim JSON As New List(Of SearchParameters)() Dim dtst As New DataTable() Dim myList As New dsStockTableAdapters.newSTOCK_LISTTableAdapter() dtst = myList.GetData(MAKE.SelectedValue, "0", "0", "0", "0", DisplayType, "", "", "", "Any", "", "", "", "", "", 0, "", "", 0, "") Try For Each rdr As DataRow In dtst.Rows Dim SRCH As New SearchParameters() SRCH.CHASSIS_NO = rdr("CHASSIS_NO").ToString() SRCH.MODEL = rdr("MODEL").ToString() SRCH.color = rdr("color").ToString() SRCH.TRANSMISSION = rdr("TRANSMISSION").ToString() SRCH.DOOR = rdr("DOOR").ToString() SRCH.MAKE = rdr("MAKE").ToString() SRCH.Image1 = rdr("Image1").ToString() SRCH.MODEL_DESCRIPTION = rdr("MODEL_DESCRIPTION").ToString() JSON.Add(SRCH) Next Catch Finally End Try Return JSON.ToArray() End Function End Class </code></pre> <p>Now a "MAKE" property always showing the first selected value which is 0 infect i am selecting the other value in dropdownlist but it`s always showing first value "0" while debuging.</p> <p>how to access the dropdownlist selected value in static method???</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload