how to give gridview cell spacing?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bbaamm
    New Member
    • Jul 2010
    • 8

    how to give gridview cell spacing?

    we are working in grid view
    in one grid each cell have childgrids and that child grid each cell contains 7 colmns and that 7 columns bind data from database but the cell spacing is not equal.


    here i attached my code and source code

    plz give me any suggestions...
    Attached Files
  • MrMancunian
    Recognized Expert Contributor
    • Jul 2008
    • 569

    #2
    I'm not going to download files with code. You can post all relevant code in CODE-tags in your reply.

    Steven

    Comment

    • bbaamm
      New Member
      • Jul 2010
      • 8

      #3
      Code:
      Protected Sub btnClass1Rev_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClass1Rev.Click
      
              conn.Open()
      
              da = New OracleDataAdapter("Select distinct hqcs_plazano from hq_plazasetup HQ_ENTRY where " & _
                        "hqcs_plazatype = 'ENTRY' or hqcs_plazatype = 'EXIT' or hqcs_plazatype = 'MIXED' or hqcs_plazatype = 'OPEN' order by hqcs_plazano asc", OraCon2)
              da.Fill(ds)
      
              GridView1.DataSource = ds
              GridView1.DataBind()
      
              For i As Integer = 0 To GridView1.Rows.Count - 1
                  Dim myTemplateField As New TemplateField()
                  Dim lblCol As Label = DirectCast(GridView1.Rows(i).Cells(0).FindControl("lbl"), Label)
                  myTemplateField.HeaderText = lblCol.Text
                  myTemplateField.ItemTemplate = New DynamicGridTemplate("GridView" & (i + 2))
      
                  GridView1.Columns.Add(myTemplateField)
                  GridView1.DataBind()
      
              Next
      
              Dim header As Integer = 0
              For i As Integer = 0 To GridView1.Rows.Count - 1
                  Dim lblrow As Label = DirectCast(GridView1.Rows(i).Cells(0).FindControl("lbl"), Label)
                  For j As Integer = 1 To GridView1.Columns.Count - 1
                      Dim ds1 As New DataSet()
                      Dim value As Integer = Convert.ToInt32(GridView1.Columns(j).HeaderText)
                      da = New OracleDataAdapter("SELECT distinct hqtf_SPfareamt1 as FA, hqtf_SPVatAmt1 as SV,hqtf_SPfareamt1 + hqtf_SPVatamt1 AS T1,hqtf_OriginSPFareamt1 as OA,hqtf_OriginSpVatamt1 as OSV,hqtf_OriginSPFareamt1 + hqtf_OriginSpVatamt1 AS T2,hqtf_SPfareamt1+hqtf_SPVatAmt1+ hqtf_OriginSPFareamt1 + hqtf_OriginSpVatamt1 as GT FROM HQ_TollFare where HQTF_Plazano = " & lblrow.Text & " and HQTF_OriginPlaza= " & value, OraCon2)
                      da.Fill(ds1)
                      'Dim table As New DataTable()
      
                      'a function that fills the datatable
                      'If ds1.Tables.Count = 0 Then
                      '    Dim row As DataRow = ds.Tables("HQ_TollFare").NewRow()
                      '    row(0) = "none"
                      '    ds1.Tables("HQ_TollFare").Rows.Add(row)
                      'End If
                      Dim grd As GridView = DirectCast(GridView1.Rows(i).Cells(j).FindControl("GridView" & (j + 1)), GridView)
                      grd.DataSource = ds1
      
                      'If ds1.Tables(0).Rows.Count > 0 And header = 0 Then
                      '    grd.ShowHeader = True
                      '    header = header + 1
                      'Else
                      '    grd.ShowHeader = False
                      'header = header + 1
                      'End If
                      If i <> 0 Then
                          grd.ShowHeader = False
      
                      Else
                          grd.ShowHeader = True
                      End If
                      grd.DataBind()
      
                  Next
              Next
          End Sub
      
      End Class

      -------------------------------

      source code:-


      Code:
      <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
              <Columns>
                  <asp:TemplateField HeaderText="Entry/Exit">
                      <ItemTemplate>
                          <%--<asp:Label ID="lbl" runat="server"></asp:Label>--%>
                          <asp:Label ID="lbl" runat="server" Text='<%#Eval("hqcs_plazano").ToString()%>'></asp:Label>
                      </ItemTemplate>
                  </asp:TemplateField>
              </Columns>
          </asp:GridView>

      Comment

      Working...