更新时间:2023-12-06 15:35:58
你好b $ b
试一试样品,这可能对你有所帮助..< html xmlns = http://www.w3.org/1999/xhtml >
< head runat = server >
< title > < / title >
< script src = jquery-1.10.2.js 类型 = text / javascript > < / script >
< script type = text / javascript >
var showimage = function(thisobject){
var image =
( 'IMG [ID * = imageFaculty]',
(的thisObject).parent()的父());
if(image.css('display')=='block')
image.css('display','none');
else
image.css('display','block');
}
< / script >
< / head >
< 正文 >
< 表格 id = form1 runat = 服务器 >
< asp:按钮 ID = Button1 runat = 服务器 文字 = 按钮 OnClientClick = validateradios();返回false; / >
< asp:GridView ID = GridView1 runat = server AutoGenerateColumns = False 宽度 = 100% >
< 列 >
< asp:TemplateField HeaderText = 必读访问 >
< ItemTemplate >
< asp:LinkButton ID = btnFaculty runat = server OnClientClick = showimage(this); return false;
文字 =' < ;% #Eval( Faculty)%> ' > < / asp:LinkButton >
< / ItemTemplate >
< / asp:TemplateField >
< ; asp:TemplateField HeaderText = 必需访问权 >
< ItemTemplate >
< asp:图像 ID = imageFaculty ImageUrl =' <% #Eval( imageurl)%> ' runat = server 样式 = display:none / >
< / ItemTemplate >
< / asp:TemplateField >
< /列 >
< / asp:GridView >
< / form >
< / body >
< / html >
b $ b受保护 void Page_Load( object sender,EventArgs e)
{
if (!Page.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add( Faculty, typeof ( string ));
dt.Columns.Add( imageurl, typeof ( string ));
dt.Rows.Add( sathish, clickMe.png);
dt.Rows.Add( karthik, clickMe.png);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
注意:添加Jquery参考它...
http://code.jquery.com/jquery- 1.10.2.min.js [ ^ ]
In Gridview
as follows
Faculty Name Photo 1 2 3
Sathish Dropdownlist1 Dropdownlist2 Dropdownlist3
In the GridView
when i click the Sathish(Faculty Name) i want to show the image in Photo column in the GridView
.
for that how can i do in asp.net using C#.
Hi
Try this sample , this might help you..<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="jquery-1.10.2.js" type="text/javascript"></script> <script type="text/javascript"> var showimage = function (thisobject) { var image =
('img[id*="imageFaculty"]',
(thisobject).parent().parent()); if( image.css('display') == 'block') image.css('display', 'none'); else image.css('display', 'block'); } </script> </head> <body> <form id="form1" runat="server"> <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="validateradios(); return false;" /> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="100%"> <Columns> <asp:TemplateField HeaderText="Required Access"> <ItemTemplate> <asp:LinkButton ID="btnFaculty" runat="server" OnClientClick="showimage(this); return false;" Text='<%# Eval("Faculty") %>'></asp:LinkButton> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Required Access"> <ItemTemplate> <asp:Image ID="imageFaculty" ImageUrl='<%# Eval("imageurl") %>' runat="server" Style="display: none" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </form> </body> </html>
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { DataTable dt = new DataTable(); dt.Columns.Add("Faculty", typeof(string)); dt.Columns.Add("imageurl", typeof(string)); dt.Rows.Add("sathish", "clickMe.png"); dt.Rows.Add("karthik", "clickMe.png"); GridView1.DataSource = dt; GridView1.DataBind(); } }
note: Add Jquery reference to it..
http://code.jquery.com/jquery-1.10.2.min.js[^]