Hi,
I have a Repeater control which is bound to a dataset. In the footer of the
repeater control, I have a Button whose visibility I want to vary according
to the sum of a column being > 0.
I have tried to set the button's visibility in Page_Load (after data
binding), but I get a NullReferenceEx ception stating that "Object reference
not set to an instance of an object".
I'm sure this has to do with when my repeater control and it's contained
controls are being rendered, I've tried putting the logic in several places
but I can't figure it out. Below is the code; thank you for any help.
-Keith
=============== =============== ============
WebForm.aspx
=============== =============== ============
<asp:Repeater id="Repeater1" runat="server">
<HeaderTemplate >
<table>
<tr>
<td>Name</td>
<td>Num Users</td>
</tr>
</HeaderTemplate>
<ItemTemplate >
<tr>
<td><%# DataBinder.Eval (Container.Data Item,"GroupName ") %></td>
<td><%# DataBinder.Eval (Container.Data Item,"NumUsers" ) %></td>
</tr>
</ItemTemplate>
<FooterTemplate >
<tr>
<td>
<asp:Button id="buttonNext " runat="server" Text="Next"
OnClick="button Next_Click" Visible="True"> </asp:Button>
</td>
</tr>
</table>
</FooterTemplate>
=============== =============== ============
WebForm.aspx.cs
=============== =============== ============
....
protected System.Web.UI.W ebControls.Repe ater Repeater1;
protected System.Web.UI.W ebControls.Butt on buttonNext;
....
private void Page_Load(objec t sender, System.EventArg s e)
{
this.Repeater1. DataSource=dsDa taSet;
this.Repeater1. DataBind();
object
sum=dsDataSet.T ables[0].Compute("SUM(N umUsers)","NumU sers=NumUsers") ;
buttonNext.Visi ble=( (int)sum > 0 );
} 1 1740
There are events for this sort of thing, like ItemCreated... Where you can
access your e.Item and then go look for controls on it.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Keith Harris" <Ke*********@di scussions.micro soft.com> wrote in message
news:EE******** *************** ***********@mic rosoft.com... Hi,
I have a Repeater control which is bound to a dataset. In the footer of the repeater control, I have a Button whose visibility I want to vary according to the sum of a column being > 0.
I have tried to set the button's visibility in Page_Load (after data binding), but I get a NullReferenceEx ception stating that "Object reference not set to an instance of an object".
I'm sure this has to do with when my repeater control and it's contained controls are being rendered, I've tried putting the logic in several places but I can't figure it out. Below is the code; thank you for any help.
-Keith
=============== =============== ============ WebForm.aspx =============== =============== ============ <asp:Repeater id="Repeater1" runat="server"> <HeaderTemplate > <table> <tr> <td>Name</td> <td>Num Users</td> </tr> </HeaderTemplate> <ItemTemplate > <tr> <td><%# DataBinder.Eval (Container.Data Item,"GroupName ") %></td> <td><%# DataBinder.Eval (Container.Data Item,"NumUsers" ) %></td> </tr> </ItemTemplate> <FooterTemplate > <tr> <td> <asp:Button id="buttonNext " runat="server" Text="Next" OnClick="button Next_Click" Visible="True"> </asp:Button> </td> </tr> </table> </FooterTemplate>
=============== =============== ============ WebForm.aspx.cs =============== =============== ============ ... protected System.Web.UI.W ebControls.Repe ater Repeater1; protected System.Web.UI.W ebControls.Butt on buttonNext; ... private void Page_Load(objec t sender, System.EventArg s e) { this.Repeater1. DataSource=dsDa taSet; this.Repeater1. DataBind();
object sum=dsDataSet.T ables[0].Compute("SUM(N umUsers)","NumU sers=NumUsers") ;
buttonNext.Visi ble=( (int)sum > 0 ); } This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Stephen |
last post by:
Hi,
I have a quick question. I am displaying all the orders that are active. I
am making use of a datarepeater with checkboxes to display data and a submit
button to insert into the database.
suppose i want to make the orders inactive using the checkboxes and click on
the submit button should update the database.
How do I capture the event such that only those check boxes that have been
|
by: Fraggle |
last post by:
I have a repeater with controls added at run time. the <template> also
contains a <asp:textbox that is made visible on some repeater
elements.
when I come to read the text info out it has disapeared. The read is
done on a button click.
I can read the selected items from the other controls in the repeater,
demo page here
|
by: Darren Smith |
last post by:
Hi There,
I have a shopping cart app that displays products along with a textbox
(to enter quantity) and an image button to add the item to the
shopping cart. Please explain why my below Button_Click procedure
does not retrieve the value of the textbox where the button was
clicked.
Thanks in Advance,
|
by: Z D |
last post by:
Hello,
I have a checkbox control as one of the items within my repeater control.
I've set the AutoPostBack=True on the checkbox.
How do I access the event (so that I can run some code) whenever someone
clicks on the checkbox? Also, how do I determine which checkbox was clicked
so that I can run the appropriate code?
|
by: Keith Harris |
last post by:
Hi,
I have a Repeater control which is bound to a dataset. In the footer of the
repeater control, I have a Button whose visibility I want to vary according
to the sum of a column being > 0.
I have tried to set the button's visibility in Page_Load (after data
binding), but I get a NullReferenceException stating that "Object reference
not set to an instance of an object".
| |
by: Joe |
last post by:
Hi,
I have a MS Access DB in which a record has just too many fields to be able
to allow users to do inline editing in a datagrid. So I want to display as
First Name: Text box where first name is displayed and can be edited.
Last Name: Text box where last name is displayed and can be edited.
At the end of this list, I want to have two buttons, update and cancel.
|
by: Shimon Sim |
last post by:
I put linkbutton in a repeater header. I attached event handler in makeup as
onclick="btnSort_Click".
Made btnSort_Click method public. It doesn't fire if I click on it. I tried
to attach it in ItemDataBound event but I think it is too late.
What am I doing wrong?
Thanks
Shimon.
|
by: Blaine Manyluk |
last post by:
I have a very unusual request.
I need to be able to generate reports and save them as TIF
files, with full programmatic control. The application will
provide the filenames. Each page of the report will be saved
as a seperate file. All the user should have to do is press a
button to generate the TIFs, without having to "touch the meat"
of viewing the report, choosing a file path/name, answering
prompts, etc.
|
by: J055 |
last post by:
Hi
I have a dropdown control which is constructed in another dropdown control
SelectedIndexChanged event
protected void ddlParamType_SelectedIndexChanged(object sender, EventArgs e)
{
// some other code
DropDownList ddlGroups = new DropDownList();
ddlGroups.SelectedIndexChanged += new
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |