我们可以在网格视图项目templet中使用和数据绑定html图像控件吗 [英] can we use and data bind html image control in grid view item templet

查看:88
本文介绍了我们可以在网格视图项目templet中使用和数据绑定html图像控件吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生想问你,在网格视图中我有3个字段,而在一个字段中我想要显示图像,我可以使用简单的html图像按钮并将其绑定,因为我们绑定了asp图像按钮.请回答...

Sir want to ask u that in grid view i have 3 field and in one field i want to show image for that can i use simple html image button and bind it as we bind the asp image button. plz reply...

推荐答案

是的.您只需要创建自己的模板即可发出所需的HTML.
Yes, of course. You just need to create your own template to emit the HTML that you require.


您可以绑定任何一个图像按钮,但是如果您在该按钮上引发了任何事件,则可以创建asp或html.如果您添加html使其在服务器b上运行,那么您必须确定在行命令事件中写入哪一个事件,即使该aslo您可以保留在图像按钮(asp/html)中的commandname和commandArgument,所以最好在其中使用asp可以在后面的代码中创建事件和访问.
参见示例

< asp:GridView ID ="GridView1" ShowFooter ="true" SkinID ="GridView" runat =服务器" Width ="100%" ToolTip ="FoodCalender"
Visible ="true" OnRowCommand ="GridView1_RowCommand1" OnPageIndexChanging ="GridView1_PageIndexChanging" DataKeyNames ="intFoodCalendarId">
<专栏>
< asp:TemplateField HeaderText ="FoodCalendar Id">
< ItemTemplate>

< asp:Label ID ="LblCalendar" runat ="server" Text =''<%#Eval("intFoodCalendarId")%>''></asp:Label>
</ItemTemplate>
< ItemStyle Horizo​​ntalAlign ="Left"/>
< HeaderStyle Horizo​​ntalAlign ="Left"/>
</asp:TemplateField>

< asp:TemplateField HeaderText =日期">
< ItemTemplate>

< asp:Label ID ="LblDate" runat ="server" Text =''<%#Eval("Dates","{0:d}")%>''></asp:Label> ;
</ItemTemplate>
< ItemStyle Horizo​​ntalAlign ="Left"/>
< HeaderStyle Horizo​​ntalAlign ="Left"/>
</asp:TemplateField>
< asp:TemplateField HeaderText ="Day">
< ItemTemplate>

< asp:Label ID ="LblDay" runat ="server" Text =''<%#Eval("Day")%>''></asp:Label>
</ItemTemplate>
< ItemStyle Horizo​​ntalAlign ="Left"/>
< HeaderStyle Horizo​​ntalAlign ="Left"/>
</asp:TemplateField>
< asp:TemplateField HeaderText =服务类型">
< ItemTemplate>
< asp:标签ID ="Lblservingtype" runat =服务器" Text =''<%#Eval("ServingName")%>''></asp:Label>
</ItemTemplate>
< ItemStyle Horizo​​ntalAlign ="Left"/>
< HeaderStyle Horizo​​ntalAlign ="Left"/>
</asp:TemplateField>
< asp:TemplateField HeaderText =食品名称">
< ItemTemplate>
< asp:标签ID ="Lblfoodname" runat =服务器" Text =''<%#Eval("ItemNames")%>''></asp:Label>
</ItemTemplate>
< ItemStyle Horizo​​ntalAlign ="Left"/>
< HeaderStyle Horizo​​ntalAlign ="Left"/>
</asp:TemplateField>
< asp:TemplateField HeaderText ="Edit">
< ItemTemplate>
< asp:ImageButton ID ="imgEdit" runat ="server" SkinID ="EditButton" CommandArgument =''<%#Eval("ItemNames")%>''
CommandName ="EditFoodCalender"/>

</ItemTemplate>
< ItemStyle Horizo​​ntalAlign ="Center"/>
</asp:TemplateField>

< asp:TemplateField>
< HeaderTemplate>
< input id ="chkAll" onclick ="javascript:SelectAllCheckboxes(this);" runat ="server" type ="checkbox"/>
</HeaderTemplate>
< ItemTemplate>
< asp:CheckBox ID ="chk" AutoPostBack ="false" runat ="server"/>
</ItemTemplate>

< FooterTemplate>
< asp:Button ID ="btnDelete" runat ="server" Font-Size ="10pt" OnClick ="btnDelete_OnClick" CommandName ="Delete" ToolTip =删除所有选中的项目" Text ="Delete"/>
</FooterTemplate>
</asp:TemplateField>
</列>
</asp:GridView>
Hi is it possible to bind any one image button but if u have any event raising on that button u may create asp or html . if u add html give it run at server b''coz u must identify which event clinck if u wrinte in rowcommand event even that aslo u can keep in image button(asp/html) commandname and commandArgument so better to use asp in that we can create event and access in code behind also.
see the example

<asp:GridView ID="GridView1" ShowFooter="true" SkinID="GridView" runat="server" Width="100%" ToolTip="FoodCalender"
Visible="true" OnRowCommand="GridView1_RowCommand1" OnPageIndexChanging="GridView1_PageIndexChanging" DataKeyNames="intFoodCalendarId" >
<Columns>
<asp:TemplateField HeaderText="FoodCalendar Id">
<ItemTemplate>

<asp:Label ID="LblCalendar" runat="server" Text=''<%# Eval("intFoodCalendarId")%>''></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" />
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>

<asp:TemplateField HeaderText="Dates">
<ItemTemplate>

<asp:Label ID="LblDate" runat="server" Text=''<%# Eval("Dates","{0:d}")%>''></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" />
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Day">
<ItemTemplate>

<asp:Label ID="LblDay" runat="server" Text=''<%# Eval("Day")%>''></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" />
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Serving Type">
<ItemTemplate>
<asp:Label ID="Lblservingtype" runat="server" Text=''<%# Eval("ServingName")%>''></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" />
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Food Item Name">
<ItemTemplate>
<asp:Label ID="Lblfoodname" runat="server" Text=''<%# Eval("ItemNames")%>''></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" />
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:ImageButton ID="imgEdit" runat="server" SkinID="EditButton" CommandArgument=''<%#Eval("ItemNames")%>''
CommandName="EditFoodCalender" />

</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>

<asp:TemplateField>
<HeaderTemplate>
<input id="chkAll" onclick="javascript:SelectAllCheckboxes(this);" runat="server" type="checkbox" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chk" AutoPostBack="false" runat="server" />
</ItemTemplate>

<FooterTemplate>
<asp:Button ID="btnDelete" runat="server" Font-Size="10pt" OnClick="btnDelete_OnClick" CommandName="Delete" ToolTip="Removes any items that where checked" Text="Delete" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>


这篇关于我们可以在网格视图项目templet中使用和数据绑定html图像控件吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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