这是定义的函数:
Function write(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
Text1.Value = e.Item.Cells(2).Text
End Function下面的程序用到了函数:
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound
If (e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem) Then
e.Item.Attributes.Add("ondblclick", write(Me, e))
e.Item.Attributes.Add("style", "cursor:hand")
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='lightblue'")
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white'")
End If
End Sub最让我不明白的是,我把函数赋给了ondblclick属性,可当程序执行的时候(页面刚打开的时候),程序就自动执行了write函数,根本都不用我双击grid了,而且无论我双击那一条,程序都没有反应~
请问这是怎么回事啊?该怎么解决?
Function write(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
Text1.Value = e.Item.Cells(2).Text
End Function下面的程序用到了函数:
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound
If (e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem) Then
e.Item.Attributes.Add("ondblclick", write(Me, e))
e.Item.Attributes.Add("style", "cursor:hand")
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='lightblue'")
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white'")
End If
End Sub最让我不明白的是,我把函数赋给了ondblclick属性,可当程序执行的时候(页面刚打开的时候),程序就自动执行了write函数,根本都不用我双击grid了,而且无论我双击那一条,程序都没有反应~
请问这是怎么回事啊?该怎么解决?
解决方案 »
- iis上指定81端口才能访问80不行
- EF中,关于外键引发循环报错的疑惑
- 为什么我公开的母版属性不能在继承页面定义和访问?
- 求助:unique constraint 错误
- htmlinputImage在DataList中无法找到?
- 很急的问题,大侠救命!
- 请高手提供关于下载hyperlink显示aspx文件,使用户无法找到真正的下载地址的方法!
- System.Security.Cryptography.CryptographicException: 出现了内部错误。
- 請問怎樣使datagrid自動分頁時顯示的分頁按鈕不可見呀??????
- 大家来讨论一下网页提交的安全检查,我希望提交的网页允许客户录入任意字符,包括<!--之类的,怎么处理啊
- 有谁知道是否有免费的 可以接收pop3邮件的Jmail组件,
- 问个简单的问题
里面的函数应该是js的
function write(sender As Object,e As DataGridItemEventArgs)
{
document.getElementById("Text1").innerText=e.Item.Cell(0).Text;
}
</script>这样改运行的时候出错~
function write(itemValue)
{
document.all.TextBox1.value = itemValue
}
</script>.vb文件中
e.Item.Attributes.Add("ondblclick", "javascript:write("&e.Item.Cells(2).Text&")")
这种事件写法
不是这样的,我是让datagrid在web下模拟在winform下的选中效果,然后双击选中的row,触发函数,我不想用模板
________
如果是想调用服务器端的函数,只能是模拟button的回发函数
示例如下
在页面中加入一个LinkButton控件,Text="",在DataGrid的ItemDataBound中:
if (e.Item.ItemIndex >= 0)
{
e.Item.Attributes["ondbClick"] = Page.GetPostBackClientHyperlink(LinkButton1, e.Item.ItemIndex);
}
然后在LinkButton1的Click中:
DataGrid1.SelectedIndex = int.Parse(Request.Form["__EVENTARGUMENT"]);