K
Kristoffer Arfvidson
Im trying to get access to a table in codebehind, because the information in
this table is different depending on what it says in the database...
So, either I have to access it from codebehind, or Ill have to make bit of
code on the aspx page...
However, I would prefere code in the aspx page at the moment, but it seemed
easier to access thecode from codebehind...
However...
When I run the following code, (when I look at the code it generates)
I see that <asp:Table> still is visible in the HTML code, this shouldnt be,
should it?
I mean, it should have been converted to normal HTML, it dosn´t, for some
reason...
In other words, the asp:Table code Dosnt work... It simple wont compile...
Any suggestions?
------
<aspataGrid id="DataGrid1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" Font-Names="Verdana, Arial, Helvetica,
sans-serif"
AllowCustomPaging="True" GridLines="None" BorderStyle="None"
BorderWidth="0px">
<HeaderStyle Font-Names="Verdana,Arial,Helvetica,sans-serif"
Font-Bold="True" ForeColor="Black"
BackColor="Transparent"></HeaderStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<table border="0" Cellpadding="0" Cellspacing="0" Width="100%"
style="FONT-SIZE: 11px; FONT-FAMILY: Verdana, Arial, sans-serif">
<tr onMouseOver='mOvr(this,"#9090FF");' onMouseOut='mOut(this,"");'
onClick="jsfuncreadart('<%# Container.DataItem("ID") %>','<%#
Container.DataItem("Type") %>');">
<td width="10" valign="top"><img src="../bilder/tomgif.gif" width="1"
height="8"><br><img src="../bilder/tomgif.gif" width="1" height="1"><img
src="../bilder/link_pil.gif" width="8" height="7"></td><td>
<asp:Table ID="tableItem" width="100%" borderwidth="0"
cellspacing="0" cellpadding="0">
<asp:TableRow><asp:TableCell Horizontalalign="right"><img
src="../bilder/tomgif.gif" width="1" height="3"></asp:tablecell>
</asp:tableRow>
</asp:Table>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle NextPageText="Nästa &gt;" PrevPageText="&lt;
Föregående"
Mode="NumericPages"></PagerStyle>
</aspataGrid>
---
Now, there is another question I would like to have answered, when or If I
get this to work, how can I access the container object from codebehind?
Because I want to access this table and build it as I want to depending of
the information on the database, in other words...
I want to do this from the sub:
----
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound
If (e.Item.ItemType = ListItemType.Item) Then
Dim i As Integer
For i = 0 To e.Item.Controls.Count - 1
Try
'tableItem
If (e.Item.Controls(i).ID = "tableItem") Then
Dim table As Table
table = e.Item.Controls(i).Controls(1)
Dim row As TableRow
Dim cell As TableCell
row = New TableRow
cell = New TableCell
'<<<---- HERE??? HOW CAN I ACCESS <%# Container.DataItem("smallheadline") %>
?? IN THIS CODE?
'BECAUSE I NEED TO BUILD THE TABLE DEPENDING ON WHAT IT SAYS IN THE
DATABASE!!!
cell.Text = "TJABBALOOOOO!!!"
row.Cells.Add(cell)
table.Rows.Add(row)
End If
Catch
End Try
Next
End If
End Sub
this table is different depending on what it says in the database...
So, either I have to access it from codebehind, or Ill have to make bit of
code on the aspx page...
However, I would prefere code in the aspx page at the moment, but it seemed
easier to access thecode from codebehind...
However...
When I run the following code, (when I look at the code it generates)
I see that <asp:Table> still is visible in the HTML code, this shouldnt be,
should it?
I mean, it should have been converted to normal HTML, it dosn´t, for some
reason...
In other words, the asp:Table code Dosnt work... It simple wont compile...
Any suggestions?
------
<aspataGrid id="DataGrid1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" Font-Names="Verdana, Arial, Helvetica,
sans-serif"
AllowCustomPaging="True" GridLines="None" BorderStyle="None"
BorderWidth="0px">
<HeaderStyle Font-Names="Verdana,Arial,Helvetica,sans-serif"
Font-Bold="True" ForeColor="Black"
BackColor="Transparent"></HeaderStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<table border="0" Cellpadding="0" Cellspacing="0" Width="100%"
style="FONT-SIZE: 11px; FONT-FAMILY: Verdana, Arial, sans-serif">
<tr onMouseOver='mOvr(this,"#9090FF");' onMouseOut='mOut(this,"");'
onClick="jsfuncreadart('<%# Container.DataItem("ID") %>','<%#
Container.DataItem("Type") %>');">
<td width="10" valign="top"><img src="../bilder/tomgif.gif" width="1"
height="8"><br><img src="../bilder/tomgif.gif" width="1" height="1"><img
src="../bilder/link_pil.gif" width="8" height="7"></td><td>
<asp:Table ID="tableItem" width="100%" borderwidth="0"
cellspacing="0" cellpadding="0">
<asp:TableRow><asp:TableCell Horizontalalign="right"><img
src="../bilder/tomgif.gif" width="1" height="3"></asp:tablecell>
</asp:tableRow>
</asp:Table>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle NextPageText="Nästa &gt;" PrevPageText="&lt;
Föregående"
Mode="NumericPages"></PagerStyle>
</aspataGrid>
---
Now, there is another question I would like to have answered, when or If I
get this to work, how can I access the container object from codebehind?
Because I want to access this table and build it as I want to depending of
the information on the database, in other words...
I want to do this from the sub:
----
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound
If (e.Item.ItemType = ListItemType.Item) Then
Dim i As Integer
For i = 0 To e.Item.Controls.Count - 1
Try
'tableItem
If (e.Item.Controls(i).ID = "tableItem") Then
Dim table As Table
table = e.Item.Controls(i).Controls(1)
Dim row As TableRow
Dim cell As TableCell
row = New TableRow
cell = New TableCell
'<<<---- HERE??? HOW CAN I ACCESS <%# Container.DataItem("smallheadline") %>
?? IN THIS CODE?
'BECAUSE I NEED TO BUILD THE TABLE DEPENDING ON WHAT IT SAYS IN THE
DATABASE!!!
cell.Text = "TJABBALOOOOO!!!"
row.Cells.Add(cell)
table.Rows.Add(row)
End If
Catch
End Try
Next
End If
End Sub