Hi everyone,
I am having a datagrid and I want to add a summary footer to it. The thing is I want to display multiple rows containing textboxes in the footer not only one. When I added template columns with textboxes to my footer and used DataBind.Eval function to bind those rows in the footer, it didn't work, textboxes are empty. Is there a special data binding function for the datagrid footer.
My code is below. For testing purposes I use the same field to populate textboxes.
HTML Code:<asp:DataGrid id="dgFooter" runat="server" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="3" ShowFooter="True" AutoGenerateColumns="False"> <FooterStyle ForeColor="#000066" BackColor="White"></FooterStyle> <SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#669999"></SelectedItemStyle> <ItemStyle ForeColor="#000066"></ItemStyle> <HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#006699"></HeaderStyle> <Columns> <asp:TemplateColumn> <ItemTemplate> <asp:TextBox ID="txtBox" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "InstallEach")%>' Width="70px"> </asp:TextBox> </ItemTemplate> <FooterTemplate> <asp:TextBox ID="Textbox1" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "InstallEach")%>' Width="70px"> </asp:TextBox> <br /> <asp:TextBox ID="Textbox2" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "InstallEach")%>' Width="70px"> </asp:TextBox> </FooterTemplate> </asp:TemplateColumn> </Columns> <PagerStyle HorizontalAlign="Left" ForeColor="#000066" BackColor="White" Mode="NumericPages"></PagerStyle> </asp:DataGrid>
VB Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim strConn As String = "server=desktop;database=Beta;uid=sa;pwd=;" Dim Conn As New SqlConnection(strConn) Dim cmd As New SqlCommand("Select ProductID, InstallEach From Products", Conn) Dim daGrid As New SqlDataAdapter(cmd) Dim dsGrid As New DataSet daGrid.Fill(dsGrid, "Products") With dgFooter .DataSource = dsGrid.Tables("Products").DefaultView .DataBind() End With daGrid.Dispose() dsGrid.Dispose() Conn.Close() End Sub
Thanks in advance, mumick.





Reply With Quote