<asp:datalist style="text-align:left" id="DataList1" runat="server" Width="600px" RepeatColumns="2" CellSpacing="9"
CellPadding="2"
onselectedindexchanged="DataList1_SelectedIndexChanged"
onitemdatabound="DataList1_ItemDataBound" Height="167px"
HorizontalAlign="Left" RepeatDirection="Horizontal">
<ItemStyle VerticalAlign="Top" />
<ItemTemplate>
<img src="shopimage/Default_303.gif" /><b><%#Eval("classname")%></b><asp:ImageButton ID="ImageButton1" runat="server"
CommandArgument='<% #Eval("id") %>'
ImageUrl="~/shop/shopimage/shanchu.BMP" onclick="ImageButton1_Click"
/><asp:ImageButton ID="ImageButton2" runat="server"
CommandArgument='<% #Eval("id")+","+Eval("classname")%>' ImageUrl="~/shop/shopimage/bianji.BMP"
onclick="ImageButton2_Click" />
<br />
<asp:Repeater ID="Repeater1" runat="server" EnableViewState="false">
<HeaderTemplate>
<table width="100%">
<tr>
<td width="10"></td>
<td style="text-align:left">
</HeaderTemplate>
<ItemTemplate><asp:ImageButton ID="ImageButton3" runat="server"
CommandArgument='<% #Eval("id") %>'
ImageUrl="~/shop/shopimage/shanchu.BMP" onclick="ImageButton3_Click"
/> <%#Eval("classname")%>
</a><font color=#aaaaff>|</font>
</ItemTemplate>
<FooterTemplate>
</td>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:datalist>using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;public partial class shop_zujian_classmge : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
editbt.Visible = false;
setclass();
datelistbding();
}
} public void setclass()
{
this.DropDownList1.DataSource = wyssql.data.ExecProcedureSelect("getshopclass", new string[] { "classid" }, new object[] { "0" });
this.DropDownList1.DataTextField = "classname";
this.DropDownList1.DataValueField = "id";
this.DropDownList1.DataBind();
this.DropDownList1.Items.Insert(0,new ListItem("添加大类","-1"));
}
protected void inclass_Click(object sender, EventArgs e)
{
if (this.classname.Text != "")
{
if (inclass.UseSubmitBehavior == true)
{
string bigclass = this.DropDownList1.SelectedValue.ToString(); if (bigclass == "-1")
{
if (wyssql.data.ExecProcedure("inshopclass", new string[] { "classid", "classname" }, new object[] { "0", this.classname.Text.ToString().Trim() }) == true)
this.ok.Text = "添加大类成功!"; }
else if (wyssql.data.ExecProcedure("inshopclass", new string[] { "classid", "classname" }, new object[] { this.DropDownList1.SelectedValue.ToString(), this.classname.Text.ToString().Trim() }) == true)
{
this.ok.Text = "添加小类成功!";
}
else
{
this.ok.Text = "添加类别不成功!";
}
setclass();
datelistbding();
this.classname.Text = "";
Response.Redirect(Request.RawUrl);
Response.End(); }
}
}
protected void DropDownList1_DataBinding(object sender, EventArgs e)
{ } public void datelistbding()
{
this.DataList1.DataSource =wyssql.data.ExecProcedureSelect("getshopclass", new string[] { "classid" }, new object[] { "0" });
this.DataList1.DataKeyField = "id";
this.DataList1.DataBind();
}
protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
Repeater myrepeater = (Repeater)e.Item.FindControl("Repeater1");
if (myrepeater != null)
{
string bigclass = this.DataList1.DataKeys[e.Item.ItemIndex].ToString();
myrepeater.DataSource = wyssql.data.ExecProcedureSelect("getshopclass", new string[] { "classid" }, new object[] { bigclass});
myrepeater.DataBind();
}
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
ImageButton tp = (ImageButton)sender;
string id = tp.CommandArgument; wyssql.data.ExecProcedure("delshopclass", new string[] { "id" }, new object[] { id });
Response.Redirect(Request.RawUrl);
Response.End();
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
ImageButton td = (ImageButton)sender;
string[] sen = td.CommandArgument.ToString().Split(',');
string id = sen[0].ToString();
string name = sen[1].ToString();
//dropDownList.SeletedIndex = dropDownList.Items.IndexOf(dropDownList.Items.FindItemByText("公司新闻")); //dropDownList 是你在页面中的DropDownList控件
//以下是在页面中显示修改数据】
this.classname.Text = name;
this.DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByText(name));
this.id.Text = id;//存储id
//this.id.Visible = true;
datelistbding();
this.editbt.Visible = true;
this.inclass.Visible = false;
}
protected void editbt_Click(object sender, EventArgs e)
{
if (this.classname.Text != "")
{
if ( this.editbt.UseSubmitBehavior == true)
{
string bigclass = this.DropDownList1.SelectedValue.ToString(); if (wyssql.data.ExecProcedure("editshopclass", new string[] {"id", "classid", "classname" }, new object[] {this.id.Text.ToString(),"0", this.classname.Text.ToString().Trim() }) == true)
{
this.ok.Text = "修改大类成功!";
}
else
{
this.ok.Text = "添加类别不成功!";
}
setclass();
datelistbding();
this.classname.Text = "";
this.inclass.Visible = true;
this.editbt.Visible = false;
Response.Redirect(Request.RawUrl);
Response.End(); }
}
}
protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
{
string bigclassid=Parent.ID.ToString();
//control.parent
datelistbding();
}
protected void Button1_Click(object sender, EventArgs e)
{ }
}
现在imagebutton3_click事件无法实现!!!请问,大虾们,我该怎么做呢!!!
解决方案 »
- 好难啊
- 这个按钮为什么只有点击才会触发,回车不会触发呢?
- asp.net写的静态网站,有网站打包器吗,可以实现转化成.exe格式直接双击查看吗
- 求Windows下web性能测试工具。最好体积比较小,中文是最好了!
- 如何把table对象绑定到datagrid里面显示?
- 一个网页定位的问题
- @@@ win2003下如何为ASP.Net辅助线程指定运行用户 @@@
- 怎么样把一个PPT放在网页上显示
- 向数据库中INSERT INTO 时间 DataTime.Now
- ASP.NET CORE WEBAPI 项目,稳定性测试,随着运行时间的增加,响应时间逐步上涨
- 帮实现一个简单的效果,送分的
- 这个sql语句怎样改了下,能提高点速度?现在我用这个sql几千条数据,分页比较慢。
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.EditItem)
{
switch (e.CommandName)
{
case "cancel":
dalbcq.Update(bcid, "noo");
p1.Visible = false;
break;
case "ok":
Add(bcid,cqid,fck.Value);
p1.Visible = false;
BindBc(cqid);
break;
default:
break;
}
}
}