N
Nick C
Hi
I would like to insert a new row in this gridview but the showfooter=true is
not working?
thanks
N
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Public Class person
Dim _name As String
Public Property Name()
Get
Return _name
End Get
Set(ByVal value)
_name = value
End Set
End Property
End Class
Public Class PersonCollection : Inherits CollectionBase
Sub New()
MyBase.New()
End Sub
Public Property item(ByVal i As Integer)
Get
Return Me.List(i)
End Get
Set(ByVal value)
Me.List(i) = value
End Set
End Property
Public Sub add(ByVal item As person)
Me.List.Add(item)
End Sub
End Class
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
If Not IsPostBack Then
GridView2.DataSource = source()
GridView2.DataBind()
End If
End Sub
Protected Function source() As PersonCollection
Dim objPersonCollection As New PersonCollection
For a As Integer = 0 To 3
Dim objPerson As New person
objPerson.Name = "Name" + a.ToString
objPersonCollection.add(objPerson)
Next
Return objPersonCollection
End Function
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
GridView2.ShowFooter = True
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="tb" runat="server" Text="<%#Bind('name') %>"></asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="tb2" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />
</div>
</form>
</body>
</html>
I would like to insert a new row in this gridview but the showfooter=true is
not working?
thanks
N
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Public Class person
Dim _name As String
Public Property Name()
Get
Return _name
End Get
Set(ByVal value)
_name = value
End Set
End Property
End Class
Public Class PersonCollection : Inherits CollectionBase
Sub New()
MyBase.New()
End Sub
Public Property item(ByVal i As Integer)
Get
Return Me.List(i)
End Get
Set(ByVal value)
Me.List(i) = value
End Set
End Property
Public Sub add(ByVal item As person)
Me.List.Add(item)
End Sub
End Class
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
If Not IsPostBack Then
GridView2.DataSource = source()
GridView2.DataBind()
End If
End Sub
Protected Function source() As PersonCollection
Dim objPersonCollection As New PersonCollection
For a As Integer = 0 To 3
Dim objPerson As New person
objPerson.Name = "Name" + a.ToString
objPersonCollection.add(objPerson)
Next
Return objPersonCollection
End Function
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
GridView2.ShowFooter = True
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="tb" runat="server" Text="<%#Bind('name') %>"></asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="tb2" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />
</div>
</form>
</body>
</html>