hello programmers, got a problem here as you see ive created field names on database namely name, address, age, contact, department, course, company
now my teacher wants is that the name is freeze on gridview while there is a dropdownlist with just two choices (personal,work)
when i click the personal it will just show [name(freeze),address,age,contact]
and when i click work it will just show [name(freeze),department,course,company]
is there any tutorial regarding this matter?.(sir's madamme's)
i could freeze the header and the colummns [via css] but i cant think of any possible solution regarding this matter.
my trials:
I think ive got a problem since ive declared all of them template and when i sort them (i think) it will also show the header of others.
Thanks and more power sir and madamme.
regards to a student whos brain is gonna blow up ^_^
plss excuse my grammars
this is my trial codes:
for source code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.GridViewContainer
{
overflow: auto;
}
.FrozenCell
{
background-color:yellow;
position: relative;
cursor: default;
left: expression(document.getElementById("GridViewContainer").scrollLeft-2);
}
.FrozenHeader
{
background-color:yellow;
position: relative;
cursor: default;
top: expression(document.getElementById("GridViewContainer").scrollTop-2);
z-index: 10;
}
.FrozenHeader.locked
{
z-index: 99;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<div style="left: 32px; overflow: auto; width: 1030px; position: relative; top: 225px;
height: 428px">
<asp:GridView ID="GridView1" runat="server" Height="408px" Width="1006px">
<HeaderStyle CssClass="FrozenHeader" />
<Columns>
<asp:BoundField DataField="name" HeaderText="Name" >
<HeaderStyle CssClass="FrozenCell" />
<ItemStyle CssClass="FrozenCell" />
</asp:BoundField>
<asp:BoundField DataField="address" HeaderText="Address" ></asp:BoundField>
<asp:BoundField DataField="age" HeaderText="Age" ></asp:BoundField>
<asp:BoundField DataField="contact" HeaderText="Contact" ></asp:BoundField>
<asp:BoundField DataField="department" HeaderText="Department" ></asp:BoundField>
<asp:BoundField DataField="course" HeaderText="Course" ></asp:BoundField>
<asp:BoundField DataField="company" HeaderText="Company" ></asp:BoundField>
</Columns>
</asp:GridView>
</div>
</div>
<div style="left: 372px; width: 286px; position: relative; top: -268px; height: 29px">
<asp:DropDownList ID="DropDownList1" runat="server" Width="283px" AutoPostBack="True">
<asp:ListItem>Choose here..</asp:ListItem>
<asp:ListItem>personal</asp:ListItem>
<asp:ListItem>work</asp:ListItem>
</asp:DropDownList></div>
</form>
</body>
</html>
for vb codes:
Imports System.Math
Imports System.Web
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 DropDownList1.SelectedValue = "personal" Then
personalData()
ElseIf DropDownList1.SelectedValue = "work" Then
workData()
Else
BindData()
End If
End Sub
Public Sub BindData()
Dim strSQL As String
Dim connection As SqlConnection = New SqlConnection("Data Source=ML0003135586;Initial Catalog=TestSQL;Integrated Security=True")
strSQL = "SELECT * FROM [tryingtable]"
connection.Open()
Dim command As New SqlCommand(strSQL, connection)
GridView1.DataSource = command.ExecuteReader
GridView1.DataBind()
End Sub
Public Sub workData()
Dim strSQL As String
Dim connection As SqlConnection = New SqlConnection("Data Source=ML0003135586;Initial Catalog=TestSQL;Integrated Security=True")
strSQL = "SELECT [name],[department],[course],[company] FROM [tryingtable]"
connection.Open()
Dim command As New SqlCommand(strSQL, connection)
GridView1.DataSource = command.ExecuteReader
GridView1.DataBind()
End Sub
Public Sub personalData()
Dim strSQL As String
Dim connection As SqlConnection = New SqlConnection("Data Source=ML0003135586;Initial Catalog=TestSQL;Integrated Security=True")
strSQL = "SELECT [name],[address],[age],[contact] FROM [tryingtable]"
connection.Open()
Dim command As New SqlCommand(strSQL, connection)
GridView1.DataSource = command.ExecuteReader
GridView1.DataBind()
End Sub
End Class
like I said there is an error saying the template must have a data for example on workdata
A field or property with the name 'address' was not found on the selected data source.
and vice versa ^_^