Hello All,
I display a list of entries with a checkbox against them using a
repeater control bound to a database table. Based on the value of database
table I want to either show the checkbox for a row or not to show, how do I
accomplish that using a repeater control ?
Should I do something like this
<%if (((DataRowView) Container.DataI tem)["bThisUserHasIt "] == 0)
{ %><asp:CheckBo x ID="chkBookMark ID" text='<%#
((DataRowView)C ontainer.DataIt em)["nBookMarkI D"] %>' runat="server"
ForeColor="Whit e" Font-Size="1px" /<%} %>
(this one does not work , but I am thinking it might be possible to do it
like that, get this error, Error 2 The name 'Container' does not exist in
the current context
C:\Inetpub\wwwr oot\allenandove ry\bookmarks\re centbookmarks.a spx 24 35
C:\...\allenand overy\
)
or is there a better way to do it, checking and specifying the value in code
behind?
Thanks a lot for your support.
Imran. 4 2699
Add your checkbox with the visable attribute like this:
visable='<# ((DataRowView)C ontainer.DataIt em["bThisUserHasIt "] ==
0)?"true":"fals e"'
Hope this helps,
Arjen
"Imran Aziz" <im***@tb2.ne t> schreef in bericht
news:eg******** ******@TK2MSFTN GP09.phx.gbl... Hello All, I display a list of entries with a checkbox against them using a repeater control bound to a database table. Based on the value of database table I want to either show the checkbox for a row or not to show, how do I accomplish that using a repeater control ? Should I do something like this
<%if (((DataRowView) Container.DataI tem)["bThisUserHasIt "] == 0)
{ %><asp:CheckBo x ID="chkBookMark ID" text='<%# ((DataRowView)C ontainer.DataIt em)["nBookMarkI D"] %>' runat="server" ForeColor="Whit e" Font-Size="1px" /<%} %>
(this one does not work , but I am thinking it might be possible to do it like that, get this error, Error 2 The name 'Container' does not exist in the current context C:\Inetpub\wwwr oot\allenandove ry\bookmarks\re centbookmarks.a spx 24 35 C:\...\allenand overy\ )
or is there a better way to do it, checking and specifying the value in code behind?
Thanks a lot for your support. Imran.
The method you are trying will work with the right syntax
But i prefer to push the functionality to the code behind leaving as much
logic out of the UI as possible.
This can be done calling a method that does the functionality you've written
there,
or what i more prefer - using the ItemDataBound event
DataLists, Grids and Repeaters all have a OnItemDataBound event, where item
by item you can perform some processing.
In this case, you can determine - item by item - whether to show or hide
your checkbox.
Just ensure in that ItemDataBound event, you are checking that your not in
the header or footer.
do a check like
private void DataList_OnItem DataBound(Syste m.Object sender,
DataItemEventAr gs e)
{
if(e.Item.ItemT emplate != ItemTemplate.He ader && e.Item.ItemTemp late
!= ItemTemplate.Fo oter)
{
//Do you logic to remove checkbox here
}
}
HTH
"Imran Aziz" <im***@tb2.ne t> wrote in message
news:eg******** ******@TK2MSFTN GP09.phx.gbl... Hello All, I display a list of entries with a checkbox against them using a repeater control bound to a database table. Based on the value of database table I want to either show the checkbox for a row or not to show, how do I accomplish that using a repeater control ? Should I do something like this
<%if (((DataRowView) Container.DataI tem)["bThisUserHasIt "] == 0)
{ %><asp:CheckBo x ID="chkBookMark ID" text='<%# ((DataRowView)C ontainer.DataIt em)["nBookMarkI D"] %>' runat="server" ForeColor="Whit e" Font-Size="1px" /<%} %>
(this one does not work , but I am thinking it might be possible to do it like that, get this error, Error 2 The name 'Container' does not exist in the current context C:\Inetpub\wwwr oot\allenandove ry\bookmarks\re centbookmarks.a spx 24 35 C:\...\allenand overy\ )
or is there a better way to do it, checking and specifying the value in code behind?
Thanks a lot for your support. Imran.
understood thanks a lot Grant :)
Imran
"Grant Merwitz" <gr***@workshar e.com> wrote in message
news:e$******** ******@TK2MSFTN GP10.phx.gbl... The method you are trying will work with the right syntax
But i prefer to push the functionality to the code behind leaving as much logic out of the UI as possible.
This can be done calling a method that does the functionality you've written there,
or what i more prefer - using the ItemDataBound event
DataLists, Grids and Repeaters all have a OnItemDataBound event, where item by item you can perform some processing. In this case, you can determine - item by item - whether to show or hide your checkbox.
Just ensure in that ItemDataBound event, you are checking that your not in the header or footer. do a check like private void DataList_OnItem DataBound(Syste m.Object sender, DataItemEventAr gs e) { if(e.Item.ItemT emplate != ItemTemplate.He ader && e.Item.ItemTemp late != ItemTemplate.Fo oter) { //Do you logic to remove checkbox here } }
HTH
"Imran Aziz" <im***@tb2.ne t> wrote in message news:eg******** ******@TK2MSFTN GP09.phx.gbl... Hello All, I display a list of entries with a checkbox against them using a repeater control bound to a database table. Based on the value of database table I want to either show the checkbox for a row or not to show, how do I accomplish that using a repeater control ? Should I do something like this
<%if (((DataRowView) Container.DataI tem)["bThisUserHasIt "] == 0)
{ %><asp:CheckBo x ID="chkBookMark ID" text='<%# ((DataRowView)C ontainer.DataIt em)["nBookMarkI D"] %>' runat="server" ForeColor="Whit e" Font-Size="1px" /<%} %>
(this one does not work , but I am thinking it might be possible to do it like that, get this error, Error 2 The name 'Container' does not exist in the current context C:\Inetpub\wwwr oot\allenandove ry\bookmarks\re centbookmarks.a spx 24 35 C:\...\allenand overy\ )
or is there a better way to do it, checking and specifying the value in code behind?
Thanks a lot for your support. Imran.
Thanks Arjen this is a quick solution and works great !
Imran.
"Arjen" <bo*****@hotmai l.com> wrote in message
news:dd******** **@news6.zwoll1 .ov.home.nl... Add your checkbox with the visable attribute like this:
visable='<# ((DataRowView)C ontainer.DataIt em["bThisUserHasIt "] == 0)?"true":"fals e"'
Hope this helps, Arjen
"Imran Aziz" <im***@tb2.ne t> schreef in bericht news:eg******** ******@TK2MSFTN GP09.phx.gbl... Hello All, I display a list of entries with a checkbox against them using a repeater control bound to a database table. Based on the value of database table I want to either show the checkbox for a row or not to show, how do I accomplish that using a repeater control ? Should I do something like this
<%if (((DataRowView) Container.DataI tem)["bThisUserHasIt "] == 0)
{ %><asp:CheckBo x ID="chkBookMark ID" text='<%# ((DataRowView)C ontainer.DataIt em)["nBookMarkI D"] %>' runat="server" ForeColor="Whit e" Font-Size="1px" /<%} %>
(this one does not work , but I am thinking it might be possible to do it like that, get this error, Error 2 The name 'Container' does not exist in the current context C:\Inetpub\wwwr oot\allenandove ry\bookmarks\re centbookmarks.a spx 24 35 C:\...\allenand overy\ )
or is there a better way to do it, checking and specifying the value in code behind?
Thanks a lot for your support. Imran.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Thomas R |
last post by:
Is is possible?
In VS.NET 2003, Binding data to the repeater is easy, but when I try to add
an ASP:checkbox to the .aspx page, the designer won't recognize it, hence
the code view doesn't allow me to access it. The funny thing is that it
compiles fine, and the checkboxes are there, I just can't write to them!
Is there a way around this problem?
My HTML is as follows:
|
by: Jack Turnbull |
last post by:
Hi,
I have a Checkbox in a Repeater set to AutoPostBack = true. I have pointed
OnCheckedChanged to a Sub but it doesn't fire. If I move the checkbox out of
the Repeater it fires! Any ideas?
Thanks
|
by: Patrick.O.Ige |
last post by:
I'm DataBinding a CheckBoxList and i want to get the checkboxes selected
when the page is loaded depending on a Boolean value from the Database..
chkDebtor.DataSource = objDR
chkDebtor.DataValueField = "checked" -- this is a column in the
table that returns 1 or 0
chkDebtor.DataTextField = "DebtorCode"
chkDebtor.DataBind()
Dim i As Integer = 0
While i < chkDebtor.Items.Count
|
by: tolaskram |
last post by:
We're developing an ASP.NET 2.0 (C#) application that needs to display array
data in a tabular format. Some might say "simply use the GridView control,"
which might work for us. But, we have a couple of specific things that the
GridView may or may not be able to do (we don't know).
We need to have the checkboxes for each row and a checkbox in the header
that checks/unchecks all the checkboxes. And then we need to be able to
delete...
|
by: Alan Silver |
last post by:
Hello,
I have a repeater that has code like this...
<ItemTemplate>
<asp:CheckBox ID="chkDelete" Text="" RunAt="server"/>
.... other stuff goes here
</ItemTemplate>
There is a button below the repeater. When clicked, it is supposed to
| |
by: RichardH |
last post by:
Hi,
I have x number of table rows that all should have a checkbox and a
dropdownlist on each row. The checkbox could be checked and the dropdown
should contain y number of values that are related to the row. I can't find a
good control for this in ASP.Net 2.0.
Now I use a repeater and check the checkbox on ItemDataBound, I also fill
the dropdown on this event. My first problem is that i find this event very
messy. I have to cast...
|
by: Keith |
last post by:
I have a repeater control that contains a HeaderTemplate and an ItemTemplate.
Each item contains a checkbox with an ID of chkReconciled, and the header
contains a single checkbox with an ID of chkAll. I simply want to have
chkAll be checked if every item in the repeater has its checkbox checked. In
the code behind page, I can access the checked property of chkReconciled by
doing the following:
Dim CurrentCheckBox As CheckBox...
|
by: Keith |
last post by:
I have a repeater control that contains a HeaderTemplate and an ItemTemplate.
Each item contains a checkbox with an ID of chkReconciled, and the header
contains a single checkbox with an ID of chkAll. I simply want to have
chkAll be checked if every item in the repeater has its checkbox checked. In
the code behind page, I can access the checked property of chkReconciled by
doing the following:
Dim CurrentCheckBox As CheckBox...
|
by: c_shah |
last post by:
using VB.net (2005) ASP.net 2.0
I have a repeater control with the item template, in the item template
I have two checkboxes
How to capture event When user checks the checkboxes? What event
fires on the repeater
Repeater Control Item Template
|
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: 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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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.
| |