首页 新闻 搜索 专区 学院

请问下datagrid里面显示超级链接和按钮啊

0
悬赏园豆:5 [已解决问题] 解决于 2016-05-22 22:25

 我需要一个超级链接在datagrid里面,一点就跳转到那个页面去,还有一个按钮像这个网站一样

http://www.boxz.com/search/%E4%BD%B3%E8%83%BD600D+%E5%A5%97%E6%9C%BA

以下是我做的不知道怎么加超级链接

男人要爽的主页 男人要爽 | 初学一级 | 园豆:15
提问于:2016-05-21 21:57
< >
分享
最佳答案
0
$('#dg').datagrid({
    columns:[[
        {field:'url',title:'网址链接', width:80,
            formatter: function(value,row,index){
                return "<a href='"+value+"'>"+value+"</a>";
            }
        }
    ]]
});

上面是加链接的

 

还有样式可以参考这个

http://www.jeasyui.com/documentation/datagrid.php

 1 $('#dg').datagrid({
 2     columns:[[
 3         {field:'listprice',title:'List Price', width:80, align:'right',
 4             styler: function(value,row,index){
 5                 if (value < 20){
 6                     return 'background-color:#ffee00;color:red;';
 7                     // the function can return predefined css class and inline style
 8                     // return {class:'c1',style:'color:red'}
 9                 }
10             }
11         }
12     ]]
13 });
View Code

 

 

收获园豆:5
seayxu | 大侠五级 |园豆:5468 | 2016-05-21 22:07

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
onrowdeleting="GridView1_RowDeleting" Width="851px"
onrowdatabound="GridView1_RowDataBound"
onrowediting="GridView1_RowEditing"
onrowcancelingedit="GridView1_RowCancelingEdit"
onrowupdating="GridView1_RowUpdating" EnableModelValidation="True" CellPadding="4" ForeColor="#333333" GridLines="None" Height="138px" style="margin-left: 97px; margin-right: 0px; margin-bottom: 25px">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:TemplateField HeaderText="编号">
<%--<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("id") %>'></asp:TextBox>
</EditItemTemplate>--%>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("PriceID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="商品名称">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" MaxLength="20" Width="80" runat="server" Text='<%# Bind("PriceName") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("PriceName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="价格">
<EditItemTemplate>
<asp:TextBox ID="TextBox6" MaxLength="20" Width="80" runat="server" Text='<%# Bind("Price") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("Price") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="型号">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" MaxLength="20" Width="80" runat="server" Text='<%# Bind("Type") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("Type") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="来源">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" MaxLength="20" Width="80" runat="server" Text='<%# Bind("Form") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Form") %>'></asp:Label>
</ItemTemplate>

</asp:TemplateField>
<asp:TemplateField HeaderText="网址链接">
<EditItemTemplate>
<asp:TextBox ID="TextBox5" MaxLength="20" Width="80" runat="server" Text='<%# Bind("Url") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("Url") %>'></asp:Label>
</ItemTemplate>

</asp:TemplateField>
<asp:HyperLinkField HeaderText="价格走势"

DataNavigateUrlFormatString="http://item.jd.com/1514798.html"
>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
</asp:HyperLinkField>

 

<asp:TemplateField HeaderText="管理" ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True"
CommandName="Update" Text="更新"></asp:LinkButton>
&nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False"
CommandName="Cancel" Text="取消"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="False"
CommandName="Edit" Text="编辑"></asp:LinkButton>
&nbsp;<asp:LinkButton ID="LinkButton4" runat="server" CausesValidation="False"
CommandName="Delete" Text="删除"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
</asp:GridView>

 

我用的是这个代码啊

你有QQ吗,我发给你看看,

男人要爽 | 园豆:15 (初学一级) | 2016-05-21 22:14

@男人要爽: 好吧,我想错了,我的资料里面有。qq:2267930027

seayxu | 园豆:5468 (大侠五级) | 2016-05-21 22:17

@SeayXu: 好的,我看看

男人要爽 | 园豆:15 (初学一级) | 2016-05-22 22:22
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册