怎么样算是选中?Textbox还是checkbox还是什么????
解决方案 »
- 看看这样能不能彻底防止SQL注入????
- webservice里面除了定义方法外还能定义什么?
- asp.net+access网站如何采集人家的信息啊
- 水晶报表问题
- 关于代码创建xml的问题..谢谢
- 有谁试过群集提供asp.net的服务器?
- 2个菜鸟问题
- 关于.net的一些疑问??
- 自定义类的话,需要编译吗?谢谢!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 我的页面有多个textbox,我想在每个textbox输入完文字后,按回车键对输入的文字进行查询,该怎样?
- 在VS.NET2003代码编辑器里面能不能折叠语句块
- 在CSDN和GOOGLE上整个搜了一遍,竟没有一条和我类似的报错:“CrystalDecisions.CrystalReports.Engine.InternalException: 打开行集失败
作者:孟宪会 出自:【孟宪会之精彩世界】 发布日期:2003年6月18日 7点44分20秒
--------------------------------------------------------------------------------
下面的代码实现了如何得到点击的当前行的数据GetCurrentClickRow.aspx<%@ Page Language="vb" EnableViewState="False" AutoEventWireup="false"
Codebehind="GetCurrentClickRow.aspx.vb" Inherits="aspxWeb.mengxianhui.com.GetCurrentClickRow"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>GetCurrentClickRow</title>
<meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body style="FONT-SIZE: 9pt" MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Panel id="Panel1" runat="server">
<asp:Label id="label1" Runat="server"></asp:Label>
<asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False" CellPadding="4"
BackColor="White" BorderWidth="1px" BorderStyle="None" BorderColor="#CC9966">
<ItemStyle ForeColor="#330099" BackColor="White" Font-Size="9pt"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000" Font-Size="9pt"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="Title"></asp:BoundColumn>
<asp:BoundColumn DataField="CreateDate"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
</asp:Panel>
</form>
</body>
</HTML>GetCurrentClickRow.aspx.vbImports System
Imports System.Data
Imports System.Data.OleDbPublic Class GetCurrentClickRow
Inherits System.Web.UI.Page
Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
Protected WithEvents label1 As System.Web.UI.WebControls.Label
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid#Region " Web Form Designer Generated Code "
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Init
InitializeComponent()
End Sub#End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
label1.Text = "获得所点击行的例子"
label1.Font.Bold = True
Panel1.HorizontalAlign = HorizontalAlign.Center
DataGrid1.Columns(0).HeaderText = "文章标题"
DataGrid1.Columns(1).HeaderText = "发布时间"
DataGrid1.HeaderStyle.HorizontalAlign = HorizontalAlign.Center
DataGrid1.AlternatingItemStyle.BackColor = System.Drawing.Color.Ivory
DataGrid1.HorizontalAlign = HorizontalAlign.Center
Dim cnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
+ Server.MapPath("Test.mdb")
Dim cn As New OleDbConnection(cnString)
cn.Open()
Dim strSQL As String = "SELECT TOP 10 Title,CreateDate FROM Document ORDER BY CreateDate DESC"
Dim cmd As New OleDbCommand(strSQL, cn)
DataGrid1.DataSource = cmd.ExecuteReader
DataGrid1.DataBind()
cn.Close()
cn.Dispose()
cn = Nothing
End Sub Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound
If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then
e.Item.Attributes.Add("onclick", "this.style.backgroundColor='#FFCC66';alert('您点击的是:\n\n第" _
+ e.Item.ItemIndex.ToString() + "行\n\n文章标题是:" + e.Item.Cells(0).Text.Replace(",", "\'") + "')")
e.Item.Cells(1).Text = Format(System.Convert.ToDateTime(e.Item.Cells(1).Text.ToString()), "yyyy年M月d日")
If e.Item.Cells(0).Text.Length > 30 Then
e.Item.Attributes.Add("Title", e.Item.Cells(0).Text)
e.Item.Cells(0).Text = e.Item.Cells(0).Text.Substring(0, 28) + "…"
End If
End If
End SubEnd Class