如何在asp.net c#网站的datagridview中打开图像onClick [英] How to open an image onClick in datagridview in asp.net c# website

查看:55
本文介绍了如何在asp.net c#网站的datagridview中打开图像onClick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <%@     Page    语言  =  C#    AutoEventWireup   =  true    CodeBehind   =  gridcheck.aspx.cs   继承  =  Website.gridcheck   %>  

< !DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd >

< html xmlns = http://www.w3.org/1999 / xhtml >
< head runat = server >
< title > GridView < / title >

< / head >
< body >
< 表单 id = form1 runat = server >
< div >

< asp:GridView ID = GridView1 runat = server AutoGenerateColumns = False

< span class =code-attribute> DataSourceID = SqlDataSource1 AllowPaging = True BorderStyle =

CellSpacing = 4 GridLines = Horizo​​ntalAlign = 中心 ShowHeader = False

style = text-align:left >
< span class =code-keyword>< >
< asp:ImageField DataImageUrlField = img

DataImageUrlFormatString = 〜/ uploads / {0} ControlStyle-Height = 200px ControlStyle-Width = 200px >

< / asp:ImageField >
< / Columns >
< EmptyDataRowStyle Horizo​​ntalAlign = 中心 VerticalAlign = 中间 / >
< / asp:GridView >
< asp:SqlDataSource ID = SqlDataSource1 runat = server

ConnectionString = <跨度类= 代码pagedirective><% $的ConnectionStrings:RoughConnectionString <跨度类= 代码pagedirective>%> <跨度类= 代码-attribute>

SelectCommand = SELECT [img] FROM [uploads] > < / asp:SqlDataSource >

< / div >
< / form
>
< / body >
< / html >

解决方案
的ConnectionStrings:RoughConnectionString <跨度类= 代码pagedirective>%> <跨度类= 代码属性> <跨度class =code-attribute>

SelectCommand = SELECT [img] FROM [uploads] > < / asp:SqlDataSource >

< span class =code-keyword>< / div >
< / form >
< / body >
< / html > < /跨度>


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="gridcheck.aspx.cs" Inherits="Website.gridcheck" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head  runat="server">
    <title>GridView</title>

</head>
<body>
    <form id="form1"  runat="server">
    <div>
    
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 

            DataSourceID="SqlDataSource1" AllowPaging="True" BorderStyle="None" 

            CellSpacing="4" GridLines="None" HorizontalAlign="Center" ShowHeader="False" 

            style="text-align: left">
            <Columns>
                <asp:ImageField DataImageUrlField="img" 

                    DataImageUrlFormatString="~/uploads/{0}" ControlStyle-Height="200px" ControlStyle-Width="200px">

                </asp:ImageField>
            </Columns>
            <EmptyDataRowStyle HorizontalAlign="Center" VerticalAlign="Middle" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 

            ConnectionString="<%$ ConnectionStrings:RoughConnectionString %>" 

            SelectCommand="SELECT [img] FROM [uploads]"></asp:SqlDataSource>
    
    </div>
    </form>
</body>
</html>

解决方案

ConnectionStrings:RoughConnectionString %>" SelectCommand="SELECT [img] FROM [uploads]"></asp:SqlDataSource> </div> </form> </body> </html>


这篇关于如何在asp.net c#网站的datagridview中打开图像onClick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆