Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Does anyone know how to bind multiple labels in the datagrid footer.

I tried to do it today but I could't. I can bind labels in the DataGrid columns but not in the footer.

My html code is below:

For the test purposes I use the same database field for all labels.

 

<asp:DataGrid id="dgFooter" runat="server">
<Columns>
 <asp:TemplateColumn>
   <ItemTemplate>
     <asp:Label ID=Label1 text='<%# DataBinder.Eval      
     (Container.DataItem, "InstallEach")%>' Runat=server></asp:Label>
   </ItemTemplate>
   <FooterTemplate>
     <asp:Label ID="Label2" text='<%# DataBinder.Eval  
     (Container.DataItem, "InstallEach")%>' Runat=server>
     </asp:Label><br />
     <asp:Label ID="Label3" text='<%# DataBinder.Eval
     (Container.DataItem, "InstallEach")%>' Runat=server>
     </asp:Label>
   </FooterTemplate>
 </asp:TemplateColumn>
</Columns>
</asp:datagrid>

 

my code behind is

 

Protected Shared strSQL As String = ConfigurationSettings.AppSettings("Connection")

   Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       Try
           Dim dbConn As New SqlConnection(strSQL)
           Dim cmd As New SqlCommand("SELECT TOP 10 InstallEach, ProductID, Identifier FROM PP WHERE InstallEach > 10", dbConn)
           Dim daGrid As New SqlDataAdapter(cmd)
           Dim dsGrid As New DataSet

           daGrid.Fill(dsGrid, "Products")
           With dgTest
               .DataSource = dsGrid.Tables("Products").DefaultView
               .DataBind()
           End With

           dsGrid.Dispose()
           daGrid.Dispose()
           dbConn.Close()
       Catch ex As Exception
           Response.Write(ex.Message())
       End Try
   End Sub

 

Any thoughts on it.

Thanks, mumick

Posted
Try...

<asp:DataGrid id="dgFooter" runat="server" ShowFooter="True" >

 

I forgot to copy it into my question. I do have showfooter set to true. There is something else prevents datagrid footeritem from binding.

but thanks anyway, mumick

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...