N
News
Hi,
I need help with datalist and linkbutton. I need a LinkButton to display in
datalist if datafield "is_measure_customchecklist" in a db table set to
true.
Here is the code (in parts):
<aspataList id="dtl1"
runat="server"
DataKeyField="program_id"
OnItemCommand="DoItemSelect"
OnItemCreated="Item_Created"
OnItemDataBound="BindProgramGrid" >
<ItemTemplate>
<%# Container.DataItem("name") %>
<asp:LinkButton Visible="false" ID="managechecklist"
CommandName="managechecklist" Text="Manage Checklist" CommandArgument='<%#
DataBinder.Eval(Container.DataItem, "is_measure_customchecklist") %>'
Runat="server" />
</ItemTemplate>
<SelectedItemTemplate>
<b><%# Container.DataItem("name") %></b> <asp:LinkButton
CommandName="Editprogram" Text="Edit Program" runat="server" />
<asp:LinkButton ID="managechecklist" CommandName="managechecklist"
Text="Manage Checklist" CommandArgument='<%#
DataBinder.Eval(Container.DataItem, "is_measure_customchecklist") %>'
Runat="server" />
.....
</SelectedItemTemplate>
1. I tried with this method but can not get commandargument (understand that
commandargument is not part of DataListItemEventArgs):
Sub Item_Created(sender As Object, e As DataListItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
' Retrieve the Label control in the current DataListItem.
Dim lbtnManageCheckist As LinkButton =
CType(e.Item.FindControl("managechecklist"), LinkButton)
lbtnManageCheckist.visible = False
If lbtnManageCheckist.CommandArgument.toString() Then
lbtnManageCheckist.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(sender As Object, e As DataListCommandEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
' Retrieve the Label control in the current DataListItem.
Dim lbtnManageCheckist As LinkButton =
CType(e.Item.FindControl("managechecklist"), LinkButton)
lbtnManageCheckist.visible = False
If lbtnManageCheckist.CommandArgument.toString() Then
lbtnManageCheckist.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_customchecklist"
is true
Thank you...
I need help with datalist and linkbutton. I need a LinkButton to display in
datalist if datafield "is_measure_customchecklist" in a db table set to
true.
Here is the code (in parts):
<aspataList id="dtl1"
runat="server"
DataKeyField="program_id"
OnItemCommand="DoItemSelect"
OnItemCreated="Item_Created"
OnItemDataBound="BindProgramGrid" >
<ItemTemplate>
<%# Container.DataItem("name") %>
<asp:LinkButton Visible="false" ID="managechecklist"
CommandName="managechecklist" Text="Manage Checklist" CommandArgument='<%#
DataBinder.Eval(Container.DataItem, "is_measure_customchecklist") %>'
Runat="server" />
</ItemTemplate>
<SelectedItemTemplate>
<b><%# Container.DataItem("name") %></b> <asp:LinkButton
CommandName="Editprogram" Text="Edit Program" runat="server" />
<asp:LinkButton ID="managechecklist" CommandName="managechecklist"
Text="Manage Checklist" CommandArgument='<%#
DataBinder.Eval(Container.DataItem, "is_measure_customchecklist") %>'
Runat="server" />
.....
</SelectedItemTemplate>
1. I tried with this method but can not get commandargument (understand that
commandargument is not part of DataListItemEventArgs):
Sub Item_Created(sender As Object, e As DataListItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
' Retrieve the Label control in the current DataListItem.
Dim lbtnManageCheckist As LinkButton =
CType(e.Item.FindControl("managechecklist"), LinkButton)
lbtnManageCheckist.visible = False
If lbtnManageCheckist.CommandArgument.toString() Then
lbtnManageCheckist.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(sender As Object, e As DataListCommandEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
' Retrieve the Label control in the current DataListItem.
Dim lbtnManageCheckist As LinkButton =
CType(e.Item.FindControl("managechecklist"), LinkButton)
lbtnManageCheckist.visible = False
If lbtnManageCheckist.CommandArgument.toString() Then
lbtnManageCheckist.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_customchecklist"
is true
Thank you...