473,765 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help with hiding LinkButton in DataList

Hi,

I need help with datalist and linkbutton. I need a LinkButton to display in
datalist if datafield "is_measure_cus tomchecklist" in a db table set to
true.

Here is the code (in parts):

<asp:DataList id="dtl1"
runat="server"
DataKeyField="p rogram_id"
OnItemCommand=" DoItemSelect"
OnItemCreated=" Item_Created"
OnItemDataBound ="BindProgramGr id" >
<ItemTemplate >
<%# Container.DataI tem("name") %> &nbsp;
<asp:LinkButt on Visible="false" ID="managecheck list"
CommandName="ma nagechecklist" Text="Manage Checklist" CommandArgument ='<%#
DataBinder.Eval (Container.Data Item, "is_measure_cus tomchecklist") %>'
Runat="server" />
</ItemTemplate>

<SelectedItemTe mplate>
<b><%# Container.DataI tem("name") %></b> &nbsp; <asp:LinkButt on
CommandName="Ed itprogram" Text="Edit Program" runat="server" /> &nbsp;
<asp:LinkButt on ID="managecheck list" CommandName="ma nagechecklist"
Text="Manage Checklist" CommandArgument ='<%#
DataBinder.Eval (Container.Data Item, "is_measure_cus tomchecklist") %>'
Runat="server" />
.....
</SelectedItemTem plate>
1. I tried with this method but can not get commandargument (understand that
commandargument is not part of DataListItemEve ntArgs):

Sub Item_Created(se nder As Object, e As DataListItemEve ntArgs)
If e.Item.ItemType = ListItemType.It em Or e.Item.ItemType =
ListItemType.Al ternatingItem Then
' Retrieve the Label control in the current DataListItem.
Dim lbtnManageCheck ist As LinkButton =
CType(e.Item.Fi ndControl("mana gechecklist"), LinkButton)

lbtnManageCheck ist.visible = False
If lbtnManageCheck ist.CommandArgu ment.toString() Then
lbtnManageCheck ist.visible = True
End If

End If
End Sub
2. I tried another way, here I can get to command argument value but setting
of the link button to visible is not working:

Sub DoItemSelect(se nder As Object, e As DataListCommand EventArgs)

If e.Item.ItemType = ListItemType.It em Or e.Item.ItemType =
ListItemType.Al ternatingItem Then
' Retrieve the Label control in the current DataListItem.
Dim lbtnManageCheck ist As LinkButton =
CType(e.Item.Fi ndControl("mana gechecklist"), LinkButton)

lbtnManageCheck ist.visible = False
If lbtnManageCheck ist.CommandArgu ment.toString() Then
lbtnManageCheck ist.visible = True
End If

End If
End Sub


Can anyone advise what is the better way to get this thing working. I need
link button to appear in DataList on condition "is_measure_cus tomchecklist"
is true
Thank you...
Nov 18 '05 #1
2 2195
In #2 you wrote:

If lbtnManageCheck ist.CommandArgu ment.toString() Then
lbtnManageCheck ist.visible = True
End If

try using:
If lbtnManageCheck ist.CommandArgu ment.toString() = "True" Then ....

the .toString() method will evaluate to Boolean True if is returns anything,
I believe you are looking for the text string "True" since you are using the
toString() to convert the CommandArgument contents to a text string...

Hope this helps! :)
wardeaux

"News" <ge**@mailcity. com> wrote in message
news:bf******** ************@ma gma.ca...
Hi,

I need help with datalist and linkbutton. I need a LinkButton to display in datalist if datafield "is_measure_cus tomchecklist" in a db table set to
true.

Here is the code (in parts):

<asp:DataList id="dtl1"
runat="server"
DataKeyField="p rogram_id"
OnItemCommand=" DoItemSelect"
OnItemCreated=" Item_Created"
OnItemDataBound ="BindProgramGr id" >
<ItemTemplate >
<%# Container.DataI tem("name") %> &nbsp;
<asp:LinkButt on Visible="false" ID="managecheck list"
CommandName="ma nagechecklist" Text="Manage Checklist" CommandArgument ='<%#
DataBinder.Eval (Container.Data Item, "is_measure_cus tomchecklist") %>'
Runat="server" />
</ItemTemplate>

<SelectedItemTe mplate>
<b><%# Container.DataI tem("name") %></b> &nbsp; <asp:LinkButt on
CommandName="Ed itprogram" Text="Edit Program" runat="server" /> &nbsp;
<asp:LinkButt on ID="managecheck list" CommandName="ma nagechecklist"
Text="Manage Checklist" CommandArgument ='<%#
DataBinder.Eval (Container.Data Item, "is_measure_cus tomchecklist") %>'
Runat="server" />
....
</SelectedItemTem plate>
1. I tried with this method but can not get commandargument (understand that commandargument is not part of DataListItemEve ntArgs):

Sub Item_Created(se nder As Object, e As DataListItemEve ntArgs)
If e.Item.ItemType = ListItemType.It em Or e.Item.ItemType =
ListItemType.Al ternatingItem Then
' Retrieve the Label control in the current DataListItem.
Dim lbtnManageCheck ist As LinkButton =
CType(e.Item.Fi ndControl("mana gechecklist"), LinkButton)

lbtnManageCheck ist.visible = False
If lbtnManageCheck ist.CommandArgu ment.toString() Then
lbtnManageCheck ist.visible = True
End If

End If
End Sub
2. I tried another way, here I can get to command argument value but setting of the link button to visible is not working:

Sub DoItemSelect(se nder As Object, e As DataListCommand EventArgs)

If e.Item.ItemType = ListItemType.It em Or e.Item.ItemType =
ListItemType.Al ternatingItem Then
' Retrieve the Label control in the current DataListItem.
Dim lbtnManageCheck ist As LinkButton =
CType(e.Item.Fi ndControl("mana gechecklist"), LinkButton)

lbtnManageCheck ist.visible = False
If lbtnManageCheck ist.CommandArgu ment.toString() Then
lbtnManageCheck ist.visible = True
End If

End If
End Sub


Can anyone advise what is the better way to get this thing working. I need
link button to appear in DataList on condition "is_measure_cus tomchecklist" is true
Thank you...

Nov 18 '05 #2
Problem is, in the #2 it does not matter if it is True or "True" as I can
set the control visibility in that Sub, in the #2 method I can not get the
value of the CommandArgument which has the value of db field
"is_measure_cus tomchecklist". I can get this value in #1, where I can not
set the visiblity of the LinkButton...

"Wardeaux" <wa******@bells outh.net> wrote in message
news:um******** ******@TK2MSFTN GP10.phx.gbl...
In #2 you wrote:

If lbtnManageCheck ist.CommandArgu ment.toString() Then
lbtnManageCheck ist.visible = True
End If

try using:
If lbtnManageCheck ist.CommandArgu ment.toString() = "True" Then ....

the .toString() method will evaluate to Boolean True if is returns anything, I believe you are looking for the text string "True" since you are using the toString() to convert the CommandArgument contents to a text string...

Hope this helps! :)
wardeaux

"News" <ge**@mailcity. com> wrote in message
news:bf******** ************@ma gma.ca...
Hi,

I need help with datalist and linkbutton. I need a LinkButton to display

in
datalist if datafield "is_measure_cus tomchecklist" in a db table set to
true.

Here is the code (in parts):

<asp:DataList id="dtl1"
runat="server"
DataKeyField="p rogram_id"
OnItemCommand=" DoItemSelect"
OnItemCreated=" Item_Created"
OnItemDataBound ="BindProgramGr id" >
<ItemTemplate >
<%# Container.DataI tem("name") %> &nbsp;
<asp:LinkButt on Visible="false" ID="managecheck list"
CommandName="ma nagechecklist" Text="Manage Checklist" CommandArgument ='<%# DataBinder.Eval (Container.Data Item, "is_measure_cus tomchecklist") %>'
Runat="server" />
</ItemTemplate>

<SelectedItemTe mplate>
<b><%# Container.DataI tem("name") %></b> &nbsp; <asp:LinkButt on
CommandName="Ed itprogram" Text="Edit Program" runat="server" /> &nbsp;
<asp:LinkButt on ID="managecheck list" CommandName="ma nagechecklist"
Text="Manage Checklist" CommandArgument ='<%#
DataBinder.Eval (Container.Data Item, "is_measure_cus tomchecklist") %>'
Runat="server" />
....
</SelectedItemTem plate>
1. I tried with this method but can not get commandargument (understand

that
commandargument is not part of DataListItemEve ntArgs):

Sub Item_Created(se nder As Object, e As DataListItemEve ntArgs)
If e.Item.ItemType = ListItemType.It em Or e.Item.ItemType =
ListItemType.Al ternatingItem Then
' Retrieve the Label control in the current DataListItem.
Dim lbtnManageCheck ist As LinkButton =
CType(e.Item.Fi ndControl("mana gechecklist"), LinkButton)

lbtnManageCheck ist.visible = False
If lbtnManageCheck ist.CommandArgu ment.toString() Then
lbtnManageCheck ist.visible = True
End If

End If
End Sub
2. I tried another way, here I can get to command argument value but

setting
of the link button to visible is not working:

Sub DoItemSelect(se nder As Object, e As DataListCommand EventArgs)

If e.Item.ItemType = ListItemType.It em Or e.Item.ItemType =
ListItemType.Al ternatingItem Then
' Retrieve the Label control in the current DataListItem.
Dim lbtnManageCheck ist As LinkButton =
CType(e.Item.Fi ndControl("mana gechecklist"), LinkButton)

lbtnManageCheck ist.visible = False
If lbtnManageCheck ist.CommandArgu ment.toString() Then
lbtnManageCheck ist.visible = True
End If

End If
End Sub


Can anyone advise what is the better way to get this thing working. I need link button to appear in DataList on condition

"is_measure_cus tomchecklist"
is true
Thank you...


Nov 18 '05 #3

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

Similar topics

2
3483
by: Mark | last post by:
Hi, I have a datalist that I use to display and edit records to a user. Datalist shown below; visual basic code:----------------------------------------------------------------------- ------- <asp:datalist id="dgContributors" runat="server" DataKeyField="PersonID"> <ItemTemplate>
1
1261
by: Jenny C. | last post by:
Hi Guys I have this problem: I'm trying to put a LinkButton inside a Datalist. But I can't add an event handle for the button. If I double click on the LinkButton, I get forwarded to the method : dtlMyDataList_SelectedIndexChanged but that method is not fired when I click on one of the buttons at runtime How do I go about this? Or is it a bad idea to put a Link Button in a DataList in the first place thanks
0
847
by: Ed Chiu | last post by:
Hi, I nested a datagrid inside a datalist, inside the datalist I have a linkbutton which will toggle the datagrid between visible and invisble. Question is, I can not find a way to keep track of which datagrids should be visible or invisible. I tried to declare an arraylist variable in the code behind file, and insert an entry when one becomes available. But the arraylist varaiable is lost during the postback. By the way, in order to...
1
1543
by: Neil | last post by:
I can't get the event handling to work on Button or ImageButton inside the header of a DataList. If I change Button to LinkButton it works fine. Has anyone had this problem? I'm using c# code behind. Here are the important parts of the code: <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="true" Inherits="DataListTest.WebForm1" %> ...... <asp:DataList id="DataList1" style="Z-INDEX: 101; LEFT: 296px;
0
1158
by: R.A.M. | last post by:
Hello, Please help me in simple problem. I defined DataList, FooterTemplate with nested asp:LinkButton, and command handler procedure: <asp:DataList ID="BooksList" runat="server" OnEditCommand="BooksList_Edit" OnUpdateCommand="BooksList_Update" OnCancelCommand="BooksList_Cancel" OnDeleteCommand="BooksList_Delete"> ...
1
1026
by: R.A.M. | last post by:
Hello, Please help me in simple problem. I defined DataList, FooterTemplate with nested asp:LinkButton, and command handler procedure: <asp:DataList ID="BooksList" runat="server" OnEditCommand="BooksList_Edit" OnUpdateCommand="BooksList_Update" OnCancelCommand="BooksList_Cancel" OnDeleteCommand="BooksList_Delete"> ...
3
4017
by: R.A.M. | last post by:
Hello, Please help me in simple problem. I defined DataList, FooterTemplate with nested asp:LinkButton, and command handler procedure: <asp:DataList ID="BooksList" runat="server" OnEditCommand="BooksList_Edit" OnUpdateCommand="BooksList_Update" OnCancelCommand="BooksList_Cancel" OnDeleteCommand="BooksList_Delete"> ...
1
2709
by: SunshineInTheRain | last post by:
The following code is dynamic create dropdownmenu which data within pulled from database However, the code work well on IE but not on Firefox. On Firefox, the whole mouseover and mouseout function din't work. what is not supported on Firefox? the javascript syntax? please help as i am not familiar with javascript. thanks in advanced. this is quite urgent.... please.. By the way hope there has somebody may help me find out why the design may...
2
2794
by: sureshl | last post by:
The below workss very fine , in the type for previous, next concept for paging, i need to do with page number Like this, 1 2 3 4......23 (http://bytes.com/topic/visual-basic-net/) Like this paging in our site........ Till 4 page visible and then last page number,,,,,? Experts plz suggest ..thx...?
0
9404
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,...
0
10164
Oralloy
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...
0
9835
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7379
isladogs
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...
0
5277
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...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3926
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
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.