给你个例子,这是我自己程序中用到的一段。 后台代码中: Protected Sub WebGrid1_InitRow(ByVal sender As Object, ByVal e As ISNet.WebUI.WebGrid.RowEventArgs) If e.Row.Type = ISNet.WebUI.WebGrid.RowType.Record Then Dim cells As WebGridCellCollection = e.Row.Cells If cells(2).Text.Trim.Length > 0 Then cells(2).Text = "<a href='" + cells(2).Text + "'>点此查看</a>" Else cells(2).Text = "暂缺" End If cells(2).ForceNoEdit = True End If End Sub页面文件中: <ISWEBGRID:WEBGRID id=WebGrid1 runat="server" Width="500px" Height="250px" DataMember="INSERVICE" DataSource="<%# DsMS_Orig1 %>" OnInitializeRow="WebGrid1_InitRow">
这是一个好控件!
后台代码中:
Protected Sub WebGrid1_InitRow(ByVal sender As Object, ByVal e As ISNet.WebUI.WebGrid.RowEventArgs)
If e.Row.Type = ISNet.WebUI.WebGrid.RowType.Record Then
Dim cells As WebGridCellCollection = e.Row.Cells
If cells(2).Text.Trim.Length > 0 Then
cells(2).Text = "<a href='" + cells(2).Text + "'>点此查看</a>"
Else
cells(2).Text = "暂缺"
End If
cells(2).ForceNoEdit = True
End If
End Sub页面文件中:
<ISWEBGRID:WEBGRID id=WebGrid1 runat="server" Width="500px" Height="250px" DataMember="INSERVICE" DataSource="<%# DsMS_Orig1 %>" OnInitializeRow="WebGrid1_InitRow">
记着这点!
不能在设计器中先选择webgrid1,再选择事件生成代码。
你可以拷贝我的代码进去,然后再修改代码体,即可!