I am using a gridview to present the startdate and event name of some events that belong to a calendar.
What I want now is that you can click on the event name in the gridview and that it sets the selecteddate of the calendar to the startdate of this event.
I already transformed the BoundFields to TemplateFields, but now I'm stuck...
go to the .aspx source, change whatever the templete item to hyperlink.(Do not delete it, just change asp:textbox to asp: DropDownList for example - same for the end tag)
Please "Mark as an Answer" if you think my post had helped you!
So, it is already a label. But what code should I use to make a hyperlink of the label? I can write <a href="..." mce_href="...">...</a> for the label, but have now idea what I should write in the href...
EDIT: I didn't saw limno's solution. I will try this one first.
boemans
Member
2 Points
17 Posts
Make hyperlink of TemplateField in GridView
Aug 21, 2007 03:21 PM|LINK
Hello everyone,
I am using a gridview to present the startdate and event name of some events that belong to a calendar.
What I want now is that you can click on the event name in the gridview and that it sets the selecteddate of the calendar to the startdate of this event.
I already transformed the BoundFields to TemplateFields, but now I'm stuck...
Thanks!
mpt_fz
Participant
1184 Points
435 Posts
Re: Make hyperlink of TemplateField in GridView
Aug 21, 2007 03:43 PM|LINK
go to the .aspx source, change whatever the templete item to hyperlink.(Do not delete it, just change asp:textbox to asp: DropDownList for example - same for the end tag)
Thanks.
limno
All-Star
117336 Points
8003 Posts
Moderator
MVP
Re: Make hyperlink of TemplateField in GridView
Aug 21, 2007 03:52 PM|LINK
Here is the followup from your another question:
<asp:TemplateField HeaderText="startdate" SortExpression="startdate">
<ItemTemplate> <asp:HyperLink runat="server" ID="HyperLink1" NavigateUrl='<%# "Events.aspx?myDate=" + Eval("startdate")%>' Text='<%# Eval("startdate","{0:d}")%>'></asp:HyperLink>
</ItemTemplate> </asp:TemplateField> protected void Page_Load(object sender, EventArgs e){
string mydate1 = Request.QueryString["myDate"];if (mydate1 != null){
CalendarEvents.SelectedDate = Convert.ToDateTime(mydate1);}
else{
CalendarEvents.SelectedDate = DateTime.Now.Date;;}
}
Format your SQL query with instant sql formatter:
http://www.dpriver.com/pp/sqlformat.htm
boemans
Member
2 Points
17 Posts
Re: Make hyperlink of TemplateField in GridView
Aug 21, 2007 03:53 PM|LINK
Well, this is one column of my gridview:
<asp:TemplateField HeaderText="Start Date" SortExpression="startdate"> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Eval("startdate", "{0:d}") %>'></asp:Label> </ItemTemplate> </asp:TemplateField>So, it is already a label. But what code should I use to make a hyperlink of the label? I can write <a href="..." mce_href="...">...</a> for the label, but have now idea what I should write in the href...
EDIT: I didn't saw limno's solution. I will try this one first.
boemans
Member
2 Points
17 Posts
Re: Make hyperlink of TemplateField in GridView
Aug 21, 2007 03:58 PM|LINK
Thanks limno,
this is the right solution for my problem!