T
tshad
This is related to my other Hiding datalistitems problem that I can't seem
to solve.
I have tried different methods which all seem to work only partially.
I decided to try to use a User Control (which I'm sure is not done
correctly) and get errors as I try to execute it.
What I want to do is take all the data from between the ItemTemplate tags
and put a control there. The I hope to be able to hide all the user
controls in my list and only show one at a time. I am hoping that I won't
lose my invisible controls as I did using a <div> tag.
Here is the control I was trying to create:
*********************************************************************8
<%@ Register TagPrefix="mbrsc" Namespace="MetaBuilders.WebControls"
Assembly="MetaBuilders.WebControls.RowSelectorColumn" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web.Mail" %>
<table>
<tr>
<td>
<asp:ImageButton ID="ExpandButton" visible="false"
runat="server" Font-Size="2" ImageUrl="../images/expand.gif" Width="16"
Height="16" CommandName="Select" AlternateText="Click here to see
details"></asp:ImageButton>
<asp:ImageButton ID="CollapseButton" visible="false"
runat="server" Font-Size="2" ImageUrl="../images/collapse.gif" Width="16"
Height="16" CommandName="Select" AlternateText="Click here to see
details"></asp:ImageButton>
<asp:label id="PositionID" Visible="false" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "PositionID") %>' />
<asp:label id="QuestionUnique" Visible="false" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "QuestionUnique") %>' />
<asp:label id="QuestionType" Visible="false" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "QuestionType") %>' />
</td>
<td>
<asp:label visible=false id="Question" text=<%#
DataBinder.Eval(Container.DataItem, "Question") %> runat="server" />
</td>
</tr>
<tr>
<td>
</td><br>
<td align="right">
<aspataGrid visible="False"
border=1
id="DataGrid1"
runat="server"
Width="400px"
AutoGenerateColumns="False"
BorderColor="#999999"
gridlines="both"
ShowFooter="false"
onItemDataBound="DataGrid1_ItemDataBound">
<AlternatingItemStyle BorderWidth="0px" BorderStyle="None"
BorderColor="White" BackColor="linen"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" BackColor="#6699cc"></HeaderStyle>
<Columns>
<asp:TemplateColumn ItemStyle-Width="15" HeaderText="">
<itemtemplate>
<asp:Label ID="SortOrder" runat="server"
Text='<%# DataBinder.Eval(Container, "DataItem.SortOrder") %>'> </asp:Label>
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Answer">
<itemtemplate>
<asp:Label ID="lblAnswer" runat="server"
Text='<%# DataBinder.Eval(Container, "DataItem.Answer") %>'> </asp:Label>
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="false">
<itemtemplate>
<asp:Label ID="lblPositionID" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.PositionID") %>'> </asp:Label>
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="false">
<itemtemplate>
<asp:Label ID="lblQuestionUnique" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.QuestionUnique") %>'> </asp:Label>
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="false">
<itemtemplate>
<asp:Label ID="lblAnswerUnique" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.AnswerUnique") %>'> </asp:Label>
</itemtemplate>
</asp:TemplateColumn>
<mbrsc:RowSelectorColumn allowselectall="false"
SelectionMode="Single" HeaderText="Select" AutoPostBack="false"
OnSelectionChanged="ShowSelections" ItemStyle-Width="10%"/>
</Columns>
</aspataGrid><br id="dataGridBr" visible="false" runat="server"
/>
<asp:button visible="false" ID="submitQuestion" runat="server"
Text="Select" OnClick="submitQuestion_click" />
</td>
</tr>
</table>
*******************************************************************************************
At first I got an error:
Parser Error Message: Object reference not set to an instance of an object.
This was caused by my 3rd party control, so I added this line from the
original file:
<%@ Register TagPrefix="mbrsc" Namespace="MetaBuilders.WebControls"
Assembly="MetaBuilders.WebControls.RowSelectorColumn" %>
Then I got an error:
Compiler Error Message: BC30456: 'DataItem' is not a member of
'System.Web.UI.Control'.
I added the imports from the first file:
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
But I still get that error.
What am I missing here and will this solve my problem?
Thanks,
Tom
to solve.
I have tried different methods which all seem to work only partially.
I decided to try to use a User Control (which I'm sure is not done
correctly) and get errors as I try to execute it.
What I want to do is take all the data from between the ItemTemplate tags
and put a control there. The I hope to be able to hide all the user
controls in my list and only show one at a time. I am hoping that I won't
lose my invisible controls as I did using a <div> tag.
Here is the control I was trying to create:
*********************************************************************8
<%@ Register TagPrefix="mbrsc" Namespace="MetaBuilders.WebControls"
Assembly="MetaBuilders.WebControls.RowSelectorColumn" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web.Mail" %>
<table>
<tr>
<td>
<asp:ImageButton ID="ExpandButton" visible="false"
runat="server" Font-Size="2" ImageUrl="../images/expand.gif" Width="16"
Height="16" CommandName="Select" AlternateText="Click here to see
details"></asp:ImageButton>
<asp:ImageButton ID="CollapseButton" visible="false"
runat="server" Font-Size="2" ImageUrl="../images/collapse.gif" Width="16"
Height="16" CommandName="Select" AlternateText="Click here to see
details"></asp:ImageButton>
<asp:label id="PositionID" Visible="false" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "PositionID") %>' />
<asp:label id="QuestionUnique" Visible="false" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "QuestionUnique") %>' />
<asp:label id="QuestionType" Visible="false" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "QuestionType") %>' />
</td>
<td>
<asp:label visible=false id="Question" text=<%#
DataBinder.Eval(Container.DataItem, "Question") %> runat="server" />
</td>
</tr>
<tr>
<td>
</td><br>
<td align="right">
<aspataGrid visible="False"
border=1
id="DataGrid1"
runat="server"
Width="400px"
AutoGenerateColumns="False"
BorderColor="#999999"
gridlines="both"
ShowFooter="false"
onItemDataBound="DataGrid1_ItemDataBound">
<AlternatingItemStyle BorderWidth="0px" BorderStyle="None"
BorderColor="White" BackColor="linen"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" BackColor="#6699cc"></HeaderStyle>
<Columns>
<asp:TemplateColumn ItemStyle-Width="15" HeaderText="">
<itemtemplate>
<asp:Label ID="SortOrder" runat="server"
Text='<%# DataBinder.Eval(Container, "DataItem.SortOrder") %>'> </asp:Label>
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Answer">
<itemtemplate>
<asp:Label ID="lblAnswer" runat="server"
Text='<%# DataBinder.Eval(Container, "DataItem.Answer") %>'> </asp:Label>
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="false">
<itemtemplate>
<asp:Label ID="lblPositionID" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.PositionID") %>'> </asp:Label>
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="false">
<itemtemplate>
<asp:Label ID="lblQuestionUnique" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.QuestionUnique") %>'> </asp:Label>
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="false">
<itemtemplate>
<asp:Label ID="lblAnswerUnique" runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.AnswerUnique") %>'> </asp:Label>
</itemtemplate>
</asp:TemplateColumn>
<mbrsc:RowSelectorColumn allowselectall="false"
SelectionMode="Single" HeaderText="Select" AutoPostBack="false"
OnSelectionChanged="ShowSelections" ItemStyle-Width="10%"/>
</Columns>
</aspataGrid><br id="dataGridBr" visible="false" runat="server"
/>
<asp:button visible="false" ID="submitQuestion" runat="server"
Text="Select" OnClick="submitQuestion_click" />
</td>
</tr>
</table>
*******************************************************************************************
At first I got an error:
Parser Error Message: Object reference not set to an instance of an object.
This was caused by my 3rd party control, so I added this line from the
original file:
<%@ Register TagPrefix="mbrsc" Namespace="MetaBuilders.WebControls"
Assembly="MetaBuilders.WebControls.RowSelectorColumn" %>
Then I got an error:
Compiler Error Message: BC30456: 'DataItem' is not a member of
'System.Web.UI.Control'.
I added the imports from the first file:
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
But I still get that error.
What am I missing here and will this solve my problem?
Thanks,
Tom