This is a migrated thread and some comments may be shown as answers.

Use EmailTo as hyperlink in radgrid

3 Answers 295 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 12 Mar 2012, 08:11 PM
I am able to use this method in asp.net grids but am switching over  to radgrids in new projects.  What happens is that when I click on it it should just open the email, but with the radgird it also wants to try to navigate to the email to as well.  How can I just use it as a way to open the ema
<telerik:RadGrid ID="myRadGrid" runat="server" Width="95%" BorderWidth="1px" CellPadding="6" GridLines="None" BorderColor="#404040" Skin="Web20" ShowFooter="true">
                                <MasterTableView AutoGenerateColumns="false" DataKeyNames="intIssuedID" HierarchyDefaultExpanded="false" HierarchyLoadMode="ServerBind" Name="MasterGrid" 
                                BorderColor="#404040" Font-Size="10" Font-Names="Veranda,arial,sans-serif" HeaderStyle-HorizontalAlign="Center" GridLines="Both" BorderWidth="1px"><ItemStyle HorizontalAlign="Center" />
                                    <AlternatingItemStyle BackColor="#B0C4DE"  HorizontalAlign="Center" /><HeaderStyle ForeColor="White" Font-Bold="true" BorderColor="#404040" BorderWidth="1px" />
                                        <Columns>
                                            <telerik:GridBoundColumn DataField="strAssetNum" HeaderText="ASSET TAG #" />
                                            <telerik:GridBoundColumn DataField="Equip" HeaderText="EQUIPMENT" />
                                            <telerik:GridBoundColumn DataField="dt_Issued" HeaderText="DT_ISSUED" />
                                            <telerik:GridBoundColumn DataField="strLocation" HeaderText="LOCATION" />
                                            <telerik:GridTemplateColumn HeaderText="ISSUED TO">
                                                <ItemTemplate>
                                                     <asp:HyperLink NavigateUrl='<%# Bind("strEmail", "mailto:{0}") %>' Text='<%# Bind("IssuedTo") %>' runat="server" ID="hlEmail"></asp:HyperLink>
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridBoundColumn DataField="ftQTY" HeaderText="QTY" />
                                        </Columns>
                                </MasterTableView>
                            </telerik:RadGrid>
il of your computer.

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 13 Mar 2012, 09:30 AM
Hello Kevin,

Your code is working on my side.
Please check below code snippet.
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource"
            OnUpdateCommand="RadGrid1_UpdateCommand">
            <MasterTableView>
                <Columns>
                    <telerik:GridTemplateColumn>
                        <ItemTemplate>
                          
                            <asp:HyperLink NavigateUrl='<%# Bind("Name", "mailto:{0}") %>' Text='<%# Bind("Name") %>' runat="server" ID="hlEmail"></asp:HyperLink>
                        </ItemTemplate>
                        
                    </telerik:GridTemplateColumn>
                    <telerik:GridEditCommandColumn>
                    </telerik:GridEditCommandColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        dynamic data = new[] {
              new { ID = 1, Name ="name1"},
              new { ID = 2, Name = "name2"},
              new { ID = 3, Name = "name3"},
              new { ID = 4, Name = "Name4"},
               new { ID = 1, Name ="name5"}};
        RadGrid1.DataSource = data;
    }
 
    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {
         
    }
 
    protected void RadGrid1_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
    {
 
    }


Thanks,
Jayesh Goyani

0
Kevin
Top achievements
Rank 1
answered on 13 Mar 2012, 01:44 PM
HI,
It works and opens a email, but it also redirects the page as well to
"mailto:{0}")

with a asp.net grid it does not do this but a telerik grid leaves the page and tries to redirect it to above.
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 13 Mar 2012, 06:35 PM
Hello Kevin,

Sorry but i am not able to reproduce the issue Then also please try with below code snippet.


<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource"
            OnUpdateCommand="RadGrid1_UpdateCommand">
            <MasterTableView>
                <Columns>
                    <telerik:GridTemplateColumn>
                        <ItemTemplate>
                            <asp:HyperLink NavigateUrl='<%# Bind("Name", "mailto:{0}") %>' Text='<%# Bind("Name") %>'
                                runat="server" ID="hlEmail"></asp:HyperLink>
                                <br />
                                <a href='<%# "mailto:" + Eval("Name") %>'><%# Eval("Name") %></a>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridEditCommandColumn>
                    </telerik:GridEditCommandColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>


Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Kevin
Top achievements
Rank 1
Share this question
or