我如何在Datalist中改变形象 [英] How I Changeimage In Datalist
本文介绍了我如何在Datalist中改变形象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Datalist具有图像控制和checkbox.where图像正在从数据库中恢复。当我单击行的复选框之一时,其他行的图像将会改变。如何通过asp.net使用csharp解决它?
这是我的数据主义者:
Datalist have image control and checkbox.where image are retriving from databse. when i click one of row's checkbox then other row's image will change.How i solve it by asp.net using csharp?
Here is my datalist:
<asp:DataList ID="DataList" runat="server" RepeatColumns="3" RepeatDirection="Horizontal"
Width="50%" BorderColor="#336699" BorderStyle="Solid" BorderWidth="2px" >
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("ProductName") %>' Font-Bold="True"
Font-Size="10pt" ForeColor="#336699" Width="100%" />
<br />
<asp:Image ID="Image1" runat="server" Width="100px" Height="120px"
ImageUrl='<%# "GetImage.aspx?id=" + Eval("ProductID") %>' />
<asp:CheckBox ID="CheckBox1" runat="server" onclick = "CheckBox_Clicked(this)" />
<asp:HiddenField ID="HiddenCatID" runat="server" Value='<%# Eval("ProductID") %>' />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Top" />
</asp:DataList
>
>
推荐答案
在CheckBox
单击事件中,您可以获得当前GridViewRow
。然后找到下一个Row的索引并检索该行。现在,找到这行的图像控制并做你想做的任何事情。
参考 - GRIDVIEW上的级联下拉列表 [ ^ ]。
参见DropDownList
SelectedIndexChanged
博客中解释的事件以及如何在该事件中获取Row。您只需要使用CheckBox
单击事件并按照相同的步骤获取当前行。然后得到下一个Row Index和下一行并按照我的说法进行操作。
Inside theCheckBox
Click Event, you can get the CurrentGridViewRow
. Then find the next Row's Index and retrieve that Row. Now, find the Image Control of this Row and do whatever you want to do.
Refer - CASCADING DROPDOWNLIST ON GRIDVIEW[^].
See theDropDownList
SelectedIndexChanged
Event explained in the Blog and how to get the Row inside that Event. You just need to use useCheckBox
Click Event and follow the same procedure to get the Current Row. Then get the next Row Index and next Row and do as I said.
这篇关于我如何在Datalist中改变形象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文