battleangela
Technical User
Hi
I have a gridview and sqlconnection that work properly. I am using the windows web develop 2005 explorer edition, and made all the functions work. I tried using the this code to have a mouseover event when someone entere into the gridview. The problem is that the code does not even load. I used breakpoint to see if their was a problem but it dot even stop.
Here is the code:
Protected Sub MyGridView_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
Dim onmouseoverStyle As String = "this.style.backgroundColor='blue'"
Dim onmouseoutStyle As String = "this.style.backgroundColor='#@BackColor'"
Dim rowBackColor As String = [String].Empty
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowState = DataControlRowState.Alternate Then
rowBackColor = MyGridView.AlternatingRowStyle.BackColor.Name.Remove(0, 2)
Else
rowBackColor = MyGridView.RowStyle.BackColor.Name.Remove(0, 2)
End If
e.Row.Attributes.Add("onmouseover", onmouseoverStyle)
e.Row.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", rowBackColor))
End If
End Sub
Here is the html part:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<html xmlns=" >
<HEAD>
<TITLE>Popup Example</TITLE>
<SCRIPT LANGUAGE="JScript">
var oPopup = window.createPopup();
function ButtonClick()
{
var oPopBody = oPopup.document.body;
oPopBody.style.backgroundColor = "lightyellow";
oPopBody.style.border = "solid black 1px";
oPopBody.innerHTML = "Click outside <B>popup</B> to close.";
oPopup.show(100, 100, 180, 25, document.body);
}
</SCRIPT>
</HEAD>
<BODY>
<form runat="server">
<BUTTON onclick="ButtonClick()">Click Me!</BUTTON>
<button id="alpha" onmouseover="ButtonClick()" style="left: 124px; position: absolute; top: 11px">Move OVer</button>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:Con+PorjectConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:Con+PorjectConnectionString1.ProviderName %>"
SelectCommand="SELECT [text_course], [text_course_id] FROM [Text]"></asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource3" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" ForeColor="Black" style="left: 59px; position: absolute; top: 96px">
<Columns>
<asp:BoundField DataField="text_course" HeaderText="Course Name" SortExpression="text_course" />
<asp:BoundField DataField="text_course_id" HeaderText="Course ID" SortExpression="text_course_id" />
<asp:HyperLinkField DataTextField="text_course" HeaderText="Test" />
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
</asp:GridView>
</form>
</BODY>
</HTML>
I have a gridview and sqlconnection that work properly. I am using the windows web develop 2005 explorer edition, and made all the functions work. I tried using the this code to have a mouseover event when someone entere into the gridview. The problem is that the code does not even load. I used breakpoint to see if their was a problem but it dot even stop.
Here is the code:
Protected Sub MyGridView_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
Dim onmouseoverStyle As String = "this.style.backgroundColor='blue'"
Dim onmouseoutStyle As String = "this.style.backgroundColor='#@BackColor'"
Dim rowBackColor As String = [String].Empty
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowState = DataControlRowState.Alternate Then
rowBackColor = MyGridView.AlternatingRowStyle.BackColor.Name.Remove(0, 2)
Else
rowBackColor = MyGridView.RowStyle.BackColor.Name.Remove(0, 2)
End If
e.Row.Attributes.Add("onmouseover", onmouseoverStyle)
e.Row.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", rowBackColor))
End If
End Sub
Here is the html part:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<html xmlns=" >
<HEAD>
<TITLE>Popup Example</TITLE>
<SCRIPT LANGUAGE="JScript">
var oPopup = window.createPopup();
function ButtonClick()
{
var oPopBody = oPopup.document.body;
oPopBody.style.backgroundColor = "lightyellow";
oPopBody.style.border = "solid black 1px";
oPopBody.innerHTML = "Click outside <B>popup</B> to close.";
oPopup.show(100, 100, 180, 25, document.body);
}
</SCRIPT>
</HEAD>
<BODY>
<form runat="server">
<BUTTON onclick="ButtonClick()">Click Me!</BUTTON>
<button id="alpha" onmouseover="ButtonClick()" style="left: 124px; position: absolute; top: 11px">Move OVer</button>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:Con+PorjectConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:Con+PorjectConnectionString1.ProviderName %>"
SelectCommand="SELECT [text_course], [text_course_id] FROM [Text]"></asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource3" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" ForeColor="Black" style="left: 59px; position: absolute; top: 96px">
<Columns>
<asp:BoundField DataField="text_course" HeaderText="Course Name" SortExpression="text_course" />
<asp:BoundField DataField="text_course_id" HeaderText="Course ID" SortExpression="text_course_id" />
<asp:HyperLinkField DataTextField="text_course" HeaderText="Test" />
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
</asp:GridView>
</form>
</BODY>
</HTML>