Ask a Question related to ASP.NET General, Design and Development.
-
Arjen #1
Get a hyperlink control inside a datalist when databouding
Hello,
Here is my datalist.
<asp:DataList id="myDataList" CellPadding="4" Width="100%" runat="server">
<ItemTemplate>
<span class="Normal">
<asp:HyperLink id="link" Text='<%# Server.HtmlEncode((String)
DataBinder.Eval(Container.DataItem,"Title")) %>' NavigateUrl='<%#
DataBinder.Eval(Container.DataItem,"Url") %>' ToolTip='<%#
DataBinder.Eval(Container.DataItem,"Description") %>' runat="server" />
</span>
<br>
</ItemTemplate>
</asp:DataList>
I want to add to this hyperlink control the property target.
Some links should open inside a new window and some other not.
How can I do this?
I have tried this but it doesn't work.
private void myDataList_ItemDataBound(object sender,
System.Web.UI.WebControls.DataListItemEventArgs e) {
DataRowView drv = (DataRowView) e.Item.DataItem;
HyperLink link = (HyperLink) e.Item.FindControl("link");
if (Convert.ToBoolean(drv["NewWindow"]) == true){
link.Target = "_blank";
}
else {
link.Target = "_self";
}
}
Can somebody help me?
The error message was.
System.InvalidCastException: Specified cast is not valid.
On this line.
DataRowView drv = (DataRowView) e.Item.DataItem;
Thanks!
Arjen Guest
-
DATALIST control
Hello, I have a doubt... I have a TextBox by name txtMessage.Text ,Button by name btnSend and Datalist Control by name dltMessage i my aspx... -
DataList parrent control with a Repeater child control
I've been trying to bind a Repeater 'child control' to a DataList control and seem to have lost the plot. Tec spec: Connection to SQL server 2... -
How to access the controls that are inside of a DataList/DataGrid using JS?
My problem is simple, i have a datalist control with some controls inside of EditTemplate (the problem is the same in the DataGrid). I want to have... -
Problem with DataGrid inside a DataList
Hi. I have a problem regarding to the DataGrid_ItemDataBound event. I cant run this event when my datagrid is inside a DataList. The... -
open page externally when click on hyperlink inside datagrid
I answered it for you in the asp.net newsgroup.. Regards, Marshal Antony ..NET Developer http://www.dotnetmarshal.com "Amir Eshterayeh"...



Reply With Quote

