By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,238 Members | 1,196 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,238 IT Pros & Developers. It's quick & easy.

how to give gridview cell spacing?

P: 8
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
File Type: zip New Folder.zip (5.8 KB, 77 views)
Aug 17 '10 #1
Share this Question
Share on Google+
2 Replies


MrMancunian
Expert 100+
P: 569
I'm not going to download files with code. You can post all relevant code in CODE-tags in your reply.

Steven
Aug 17 '10 #2

P: 8
Expand|Select|Wrap|Line Numbers
  1. Protected Sub btnClass1Rev_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClass1Rev.Click
  2.  
  3.         conn.Open()
  4.  
  5.         da = New OracleDataAdapter("Select distinct hqcs_plazano from hq_plazasetup HQ_ENTRY where " & _
  6.                   "hqcs_plazatype = 'ENTRY' or hqcs_plazatype = 'EXIT' or hqcs_plazatype = 'MIXED' or hqcs_plazatype = 'OPEN' order by hqcs_plazano asc", OraCon2)
  7.         da.Fill(ds)
  8.  
  9.         GridView1.DataSource = ds
  10.         GridView1.DataBind()
  11.  
  12.         For i As Integer = 0 To GridView1.Rows.Count - 1
  13.             Dim myTemplateField As New TemplateField()
  14.             Dim lblCol As Label = DirectCast(GridView1.Rows(i).Cells(0).FindControl("lbl"), Label)
  15.             myTemplateField.HeaderText = lblCol.Text
  16.             myTemplateField.ItemTemplate = New DynamicGridTemplate("GridView" & (i + 2))
  17.  
  18.             GridView1.Columns.Add(myTemplateField)
  19.             GridView1.DataBind()
  20.  
  21.         Next
  22.  
  23.         Dim header As Integer = 0
  24.         For i As Integer = 0 To GridView1.Rows.Count - 1
  25.             Dim lblrow As Label = DirectCast(GridView1.Rows(i).Cells(0).FindControl("lbl"), Label)
  26.             For j As Integer = 1 To GridView1.Columns.Count - 1
  27.                 Dim ds1 As New DataSet()
  28.                 Dim value As Integer = Convert.ToInt32(GridView1.Columns(j).HeaderText)
  29.                 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)
  30.                 da.Fill(ds1)
  31.                 'Dim table As New DataTable()
  32.  
  33.                 'a function that fills the datatable
  34.                 'If ds1.Tables.Count = 0 Then
  35.                 '    Dim row As DataRow = ds.Tables("HQ_TollFare").NewRow()
  36.                 '    row(0) = "none"
  37.                 '    ds1.Tables("HQ_TollFare").Rows.Add(row)
  38.                 'End If
  39.                 Dim grd As GridView = DirectCast(GridView1.Rows(i).Cells(j).FindControl("GridView" & (j + 1)), GridView)
  40.                 grd.DataSource = ds1
  41.  
  42.                 'If ds1.Tables(0).Rows.Count > 0 And header = 0 Then
  43.                 '    grd.ShowHeader = True
  44.                 '    header = header + 1
  45.                 'Else
  46.                 '    grd.ShowHeader = False
  47.                 'header = header + 1
  48.                 'End If
  49.                 If i <> 0 Then
  50.                     grd.ShowHeader = False
  51.  
  52.                 Else
  53.                     grd.ShowHeader = True
  54.                 End If
  55.                 grd.DataBind()
  56.  
  57.             Next
  58.         Next
  59.     End Sub
  60.  
  61. End Class
  62.  
  63.  

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

source code:-


Expand|Select|Wrap|Line Numbers
  1. <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
  2.         <Columns>
  3.             <asp:TemplateField HeaderText="Entry/Exit">
  4.                 <ItemTemplate>
  5.                     <%--<asp:Label ID="lbl" runat="server"></asp:Label>--%>
  6.                     <asp:Label ID="lbl" runat="server" Text='<%#Eval("hqcs_plazano").ToString()%>'></asp:Label>
  7.                 </ItemTemplate>
  8.             </asp:TemplateField>
  9.         </Columns>
  10.     </asp:GridView>
  11.  
Aug 17 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.