473,383 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

User control problem

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.RowSelectorColu mn" %>
<%@ 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">
<asp:DataGrid 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>
</asp:DataGrid><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.RowSelectorColu mn" %>

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
Nov 19 '05 #1
2 3195
Hi,

"tshad" <ts**********@ftsolutions.com> wrote in message
news:O$**************@TK2MSFTNGP10.phx.gbl...
<snip>
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?
eg:
DataBinder.Eval(Container.DataItem, "PositionID")

should be

DataBinder.Eval(Container, "DataItem.PositionID")

Thanks,

Tom


Hope this helps,
Martin Dechev
ASP.NET MVP

Nov 19 '05 #2
"Martin Dechev" <de*******@hotmail.com> wrote in message
news:OK*************@tk2msftngp13.phx.gbl...
Hi,

"tshad" <ts**********@ftsolutions.com> wrote in message
news:O$**************@TK2MSFTNGP10.phx.gbl...
<snip>
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?


eg:
DataBinder.Eval(Container.DataItem, "PositionID")

should be

DataBinder.Eval(Container, "DataItem.PositionID")


Why is that different?

It did seem to get rid of that error. Now I am getting the following error:

Compiler Error Message: BC30456: 'DataGrid1_ItemDataBound' is not a member
of 'ASP.datalistitem_ascx'.

Source Error:

Line 21: </td><br>
Line 22: <td align="right">
Line 23: <asp:DataGrid visible="False"

With Line 23: highlighted. This codes was taken directly from the asp.net
page. I am trying to set an datalistitem that I can make visible and not
visible programmatically. But first I need to make it work as it was.

Here is the .aspx page (without the script code):
************************************************** ***************************************
<%@ Page Language="VB" trace="true" debug="true" AutoEventWireup="true"
ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Register TagPrefix="fts" TAgName="header"
src="..\includes\ApplicantHeaders.ascx" %>
<%@ Register TagPrefix="fts" TAgName="footer"
src="..\includes\staffingFooters.ascx" %>
<%@ Register TagPrefix="fts" TAgName="dataListItem" src="datalistitem.ascx"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ Register TagPrefix="mbrsc" Namespace="MetaBuilders.WebControls"
Assembly="MetaBuilders.WebControls.RowSelectorColu mn" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web.Mail" %>
<!-- #include file="..\includes\slidemenus.inc" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Take Screen Test</title>
<link href="staffing.css" rel="stylesheet" type="text/css">
<fts:header id=ctl1 runat="Server" />
<!-- Content Starts Here -->
<form id="Form1" runat="server">
<input type="hidden" name="__SCROLLPOS" value="" />
<center>
<br>
<table border="0" class=basicTable style="margin-left:5" >
<tr>
<th colspan="2"><asp:Label id="tableTitle" Font-Size=10
runat="server">Screen Questions and Answers</asp:Label><br>
<asp:Label id="jobTitle" Font-Size=12 runat="server"/>
</th>
</tr>
<tr>
<td>
<asp:datalist id="DataList1"
runat="server"
Width="100%"
BorderWidth="0px"
OnItemCommand="OnSelectIndexChanged"
footerstyle-horizontalalign="center"
CellPadding="0"
CellSpacing="0"
style="margin:0">
<AlternatingItemStyle cssClass=alternateRow ></AlternatingItemStyle>
<ItemTemplate>
<fts:dataListItem id=dataListItemCtl runat="Server"
/>
</ItemTemplate>
<SeparatorTemplate>
<hr visible="false" style="margin:0" runat="server" />
</SeparatorTemplate>
<FooterTemplate>
<SeparatorTemplate>
<hr style="margin:0">
</SeparatorTemplate>
<asp:Button ID="CollapseAll" visible=false text="Collapse All"
runat="server" onClick="collapseAll_click" AlternateText="Click here to see
details"></asp:Button>&nbsp;&nbsp;
<asp:Button ID="ExpandAll" visible=false text="Expand All"
runat="server" onClick="expandAll_click" AlternateText="Click here to see
details"></asp:Button>
<asp:Button ID="Submit" text=" Submit " runat="server"
onClick="submitScreenTest_click" AlternateText="Click here to see
details"></asp:Button>
</FooterTemplate>
</asp:datalist>
<asp:Label id="InfoLabel" visible="false" runat="server" Height="23px"
Width="597px" BackColor="#FFFFC0" Font-Bold="True"></asp:Label>
<font color="#FF0000">
<asp:label ID="lblErrorMessage" runat="server" />
</font>
</td>
</tr>
</table>
<asp:Label runat="server" id="Message" />
</center>
</form>

<!-- Content Ends Here -->
<fts:footer id=ctl2 runat="Server" />
************************************************** ****************************************

Here is the .ascx page:
************************************************** ****************************************
<%@ Register TagPrefix="mbrsc" Namespace="MetaBuilders.WebControls"
Assembly="MetaBuilders.WebControls.RowSelectorColu mn" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<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">
<asp:DataGrid 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>
</asp:DataGrid><br id="dataGridBr" visible="false" runat="server"
/>
<asp:button visible="false" ID="submitQuestion" runat="server"
Text="Select" OnClick="submitQuestion_click" />
</td>
</tr>
</table>
************************************************** ****************************************

I hope a user control is the way to go to solve this. I have tried a bunch
of other things that didn't work.

Thanks,

Tom.


Thanks,

Tom


Hope this helps,
Martin Dechev
ASP.NET MVP

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Earl Teigrob | last post by:
Background: When I create a ASP.NET control (User or custom), it often requires security to be set for certain functionality with the control. For example, a news release user control that is...
2
by: Sam Kuehn | last post by:
There has been a lot of articles on how to load user controls at runtime in the Init() method. UserControl myControl = (UserControl)LoadControl(stringControl); I add the control in the Init()...
6
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all...
4
by: thomson | last post by:
Hi all, i do have a user control with 4 buttons, and all the events are firing properly, My problem is that i need to right an event handler in the user control, which gets fired after a...
8
by: David Lozzi | last post by:
Howdy, I have a user control that is a report to display data. On the page the control is inserted in, I have filter options to filter the report. When I try to do something like this, nothing...
5
by: Segfahlt | last post by:
I need a little help here please. I have 2 win forms user controls in 2 different projects that I'm hosting in 2 different virtual directories. The controls have been test and operate okay in...
4
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
5
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
5
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something...
3
by: jonathan.beckett | last post by:
I have been experimenting with placing user controls (using Windows Forms controls) into an ASP.NET webpage - and am completely stuck. I can get a blank user control to work, but nothing beyond...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.