标题:[求助]怎么编译总是提示System.StackOverflowException
只看楼主
xiaofkg
Rank: 1
等 级:新手上路
威 望:1
帖 子:77
专家分:0
注 册:2007-9-17
 问题点数:0 回复次数:5 
[求助]怎么编译总是提示System.StackOverflowException

Imports System.Data.SqlClient
Imports System.Data
Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
binddropdownlist_DataBinding(sender, e)
End If
End Sub

Protected Sub binddropdownlist_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles binddropdownlist.DataBinding
Dim strCon As String
Dim strSelect As String
Dim con As SqlConnection
Dim sda As SqlDataAdapter


strCon = "Data Source=.;Initial Catalog=sheet;Integrated Security=True"
con = New SqlConnection(strCon)
strSelect = "select count(id) as id,areaBig from test group by areaBig"
sda = New SqlDataAdapter(strSelect, con)
Dim ds As New DataSet()
sda.Fill(ds, "test")
binddropdownlist.DataSource = ds
binddropdownlist.DataValueField = "id"
binddropdownlist.DataTextField = "areaBig"
binddropdownlist.DataBind()

End Sub

Protected Sub binddropdownlist_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles binddropdownlist.SelectedIndexChanged
Dim strCon As String
Dim con As SqlConnection
Dim strSelect As String
Dim sda As SqlDataAdapter

strCon = "Data Source=.;Initiial Catalog=sheet;Integrated Security=true"
con = New SqlConnection(strCon)
strSelect = "select id,areaSmall from test where areaBig='" + binddropdownlist.SelectedItem.Text + "'"
sda = New SqlDataAdapter(strSelect, con)
Dim ds As New DataSet()
sda.Fill(ds, "test")
DropDownList2.DataSource = ds
DropDownList2.DataValueField = "id"
DropDownList2.DataTextField = "areaSmall"
DropDownList2.DataBind()


End Sub
End Class

搜索更多相关主题的帖子: System 编译 提示 
2007-11-03 09:57
冰彩虹
Rank: 4
来 自:上海
等 级:贵宾
威 望:14
帖 子:806
专家分:44
注 册:2007-6-28
得分:0 
binddropdownlist数据绑定需要放在binddropdownlist_DataBinding事件里嘛?这样写,pageloadk的时候会运行,对binddropdownlist绑定时还会运行,大量的重复运行会占用系统资源的呀

直接提供一个方法不就行了

Flying without wings
2007-11-03 11:18
xiaofkg
Rank: 1
等 级:新手上路
威 望:1
帖 子:77
专家分:0
注 册:2007-9-17
得分:0 
冰彩虹你看清楚了没有啊,binddropdownlist_DataBinding只会运行一次,而且我也写了它的方法,并不存在你所说的问题
2007-11-03 14:33
xiaofkg
Rank: 1
等 级:新手上路
威 望:1
帖 子:77
专家分:0
注 册:2007-9-17
得分:0 
版主再看看,有什么问题
2007-11-03 21:07
冰彩虹
Rank: 4
来 自:上海
等 级:贵宾
威 望:14
帖 子:806
专家分:44
注 册:2007-6-28
得分:0 
那就不清楚了哦,你设置断点debug跟踪看看吧

Flying without wings
2007-11-04 19:36
xiaofkg
Rank: 1
等 级:新手上路
威 望:1
帖 子:77
专家分:0
注 册:2007-9-17
得分:0 
谢了。不过楼主我觉得这个代码段并不能实现二个dropdownlist的联动,你有什么方法吗?

[此贴子已经被作者于2007-11-5 14:24:30编辑过]


2007-11-05 13:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-183083-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.862088 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved