Saturday, 15 January 2011

vb.net - visual basic asp.net dropDownList not populating with values -


I have an asp.net visual basic web site, and I'm using an archived method so that a drop- list below.

However, I have two problems: If I put the method to fill the drop-down list in the IsPostBack statement if I do not have a page load event, then the entire list is replaced by the actual values' System. Data.DataViewRow '. If I exclude it from the 'if' statement, but still in my page load event, I get the right value, but any thing that I did not choose, when I leave the drop-down, Returns to the top object instead

What am I doing wrong ??

EDIT: As I suggested by Neck, now Dattatistfield has added and suggested to Lee that my 'I belly. However, my drop down is still showing all values ​​as 'System.Data.DataViewRow', so I do not know if Lee's solution worked or not! Any other thoughts on the point of showing the values! I updated my code below to display the changes.

Visual Basic:

  Protected sub page_load (the same sender as the object, load IV.V. as the system. If not, then PopBank then body panel. = Wrong DRP regian_fill () End and end and subscribed subsided DPREGI_fil () DM SQLcon SQL Connection sqlConn = New SQL Connection sqlConn.ConnectionString = Configuration Manager. In the form of connection strings ("Konstring"). Connection string DM Iarjiansimdi SQL Command Deepiarjiaiansimdi as = new SqlCommand ( "getRegionName", sqlConn) drpRegionCmd.CommandType = CommandType.StoredProcedure dim drpRegionAdp SqlDataAdapter drpRegionAdp = new SqlDataAdapter as (drpRegionCmd) dim drpRegionDs datasets drpRegionDs = new datasets sqlConn.Open () drpRegionAdp .Fill (drpRegionDs) as with drpRegion. DataSource = drpRegionDs .DataBind (). DataValueField = "regionName". DataTextField = "regionName". Select index = 0 sqlConn.Close (with end) end sub   

Markup:

  & lt; ASP: Panel ID = "panel reagion" runat = "server" height = "160px" width = "71%" CssClass = "inline block" & gt; & Lt; H2 & gt; Region: & lt; / H2 & gt; & Lt; asp: dropDownList runat = "server" Otopostbak = "true" id = "drpRegion" / & gt; & Lt; / ASP: Cell & gt;   

SQL procedure is a two-column dataset as the column 1 with 'Kshetraidi', and as column 2 "Area Name".

I have been trying various things for now, now and I can read all the books! I have never had this issue in C # when I did the same operation and I can not think of what I have forgotten in VB for my life ...

it is unlikely that you are set DataTextField property of DropDownList is:

  with drpRegion. Datasource = drpRegionDs .DataValueField = "Area Name" Kdetafikfild = "Fildtodasplesttekst" .SelectedIndex = 0 ends with .DataBind ()   

Source:

No comments:

Post a Comment