HyperLink Format.

I need to change the HyperLink control and all it's associated properties into a LinkButton. Is this possible?

HyperLink:
<asp:HyperLink ID="HyperLink1" NavigateUrl='<%# "Schedule.aspx?ghaoc_id=" + Eval("ghaoc_id") + "&ghaocp_id=" + Eval("ghaocp_id") %>' runat="server" Text="Schedule" />

Needs changed to LinkButton using same NaviageURL info.
LVL 4
asp_net2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

quizwedgeCommented:
Change it to <asp:LinkButton ID="HyperLink1" CommandName="HyperLink" CommandArgument='<%# "Schedule.aspx?ghaoc_id=" + Eval("ghaoc_id") + "&ghaocp_id=" + Eval("ghaocp_id") %>' runat="server" Text="Schedule" />

The CommandName can be whatever. Then, in the ItemCommand function for the repeater / datagrid / whatever you have this hyperlink in you'll need to check for the command name "HyperLink"

If e.CommandName = "HyperLink" Then
     Response.Redirect(e.CommandArgument)
End If
0
asp_net2Author Commented:
Below is my current Repeater that has the HyperLink Control.


<asp:Repeater runat="server" ID="myRepeater">
            <ItemTemplate>
                <asp:PlaceHolder ID="PlaceHolder1" runat="server" Visible='<%# lastCourseName != Eval("ghaocp_name").ToString() %>'>
                    <asp:PlaceHolder ID="PlaceHolder2" runat="server" Visible='<%# lastCourseName != null %>'>
                        <tr>
                            <td colspan="4">
                                <hr />
                            </td>
                        </tr>
                    </asp:PlaceHolder>
                    <tr>
                        <td colspan="2" class="CourseDescTitle">
                            <%# lastCourseName = Eval("ghaocp_name").ToString()%>
                        </td>
                        <td colspan="2" style="text-align: center;">
                            <asp:HyperLink ID="HyperLink1" NavigateUrl='<%# "Schedule.aspx?ghaoc_id=" + Eval("ghaoc_id") + "&ghaocp_id=" + Eval("ghaocp_id") %>' runat="server" Text="Schedule" />
                        </td>
                    </tr>
                </asp:PlaceHolder>
                <tr>
                    <td class="CourseUpdateInfo">
                        <%# Convert.ToDateTime(Eval("csch_startdate")).ToLongDateString()%>
                    </td>
                    <td class="CourseUpdateInfo">
                        <%# Eval("hmi_name").ToString()%>
                    </td>
                    <td class="CourseUpdateInfo">
                        <%# Eval("csch_starttime").ToString()%>
                    </td>
                    <td class="CourseUpdateInfo">
                        <%# Eval("csch_endtime").ToString()%>
                    </td>
                </tr>
            </ItemTemplate>
        </asp:Repeater>

Open in new window

0
quizwedgeCommented:
You'll change line 16 to what I wrote above. The second part goes in your codebheind. Are you using VB or C#?
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

asp_net2Author Commented:
using C#
0
Carlos VillegasFull Stack .NET DeveloperCommented:
Hello @asp_net2, I did the changes to your code:

Code behind:
protected void myRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
{
    if (e.CommandName == "Schedule")
    {
        string yourNavigateUrl = e.CommandArgument.ToString();
    }
}

Open in new window


html:
<asp:Repeater runat="server" ID="myRepeater" OnItemCommand="myRepeater_ItemCommand">
    <ItemTemplate>
	<asp:PlaceHolder ID="PlaceHolder1" runat="server" Visible='<%# lastCourseName != Eval("ghaocp_name").ToString() %>'>
	    <asp:PlaceHolder ID="PlaceHolder2" runat="server" Visible='<%# lastCourseName != null %>'>
		<tr>
		    <td colspan="4">
			<hr />
		    </td>
		</tr>
	    </asp:PlaceHolder>
	    <tr>
		<td colspan="2" class="CourseDescTitle">
		    <%# lastCourseName = Eval("ghaocp_name").ToString()%>
		</td>
		<td colspan="2" style="text-align: center;">
			<asp:LinkButton Text="Schedule" runat="server" CommandName="Schedule" CommandArgument='<%# "Schedule.aspx?ghaoc_id=" + Eval("ghaoc_id") + "&ghaocp_id=" + Eval("ghaocp_id") %>' />
		</td>
	    </tr>
	</asp:PlaceHolder>
	<tr>
	    <td class="CourseUpdateInfo">
		<%# Convert.ToDateTime(Eval("csch_startdate")).ToLongDateString()%>
	    </td>
	    <td class="CourseUpdateInfo">
		<%# Eval("hmi_name").ToString()%>
	    </td>
	    <td class="CourseUpdateInfo">
		<%# Eval("csch_starttime").ToString()%>
	    </td>
	    <td class="CourseUpdateInfo">
		<%# Eval("csch_endtime").ToString()%>
	    </td>
	</tr>
    </ItemTemplate>
</asp:Repeater>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
asp_net2Author Commented:
Thank you very much for helping with this post!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.