【GridView】插入自定义方法
一个gridview里面我想添加自定义方法,要如何添加,.
之前我是把方法写在OnSelectedIndexChanging和OnRowDeleting这两个里面.,.
但这个现在都已经写有方法了.,我要如何在添加自定义方法呢.,.
[解决办法]
不明白你要实现什么功能。
[解决办法]
搞不清你要做什么。
[解决办法]
继承gridview
[解决办法]
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { LinkButton linkbutton1 = sender as LinkButton ; int index = (linkbutton1.NamingContainer as GridViewRow).RowIndex; string name= GridView1.Rows[index].Cells["Name"].InnerText; }
[解决办法]
LinkButton_OnClick
[解决办法]
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" DataKeyNames="ID" > <Columns> <asp:TemplateField> <ItemTemplate> <asp:LinkButton ID="LinkButton1" runat="server" AutoPostBack="true" OnClick="LinkButton_OnClick" > </ItemTemplate> </asp:TemplateField> <asp:BoundField ShowHeader="true" DataField="ID" HeaderText="ID" /> <asp:BoundField ShowHeader="true" DataField="name" HeaderText="姓名" /> </Columns></asp:GridView> <span>评价:</span><asp:TextBox ID="SelectedRLText" runat="server" Text=""></asp:TextBox>
[解决办法]
你继承gridview自定义控件里
public event EventHandler BeforeSelectIndexchanged;
protected override void OnSelectedIndexChanged(EventArgs e)
{
BeforeSelectIndexchanged(this, EventArgs.Empty);
base.OnSelectedIndexChanged(e);
}
页面使用
this.YourGridView1.BeforeSelectIndexchanged += new EventHandler(YourGridView1_BeforeSelectIndexchanged);
或者直接在设计试图里添加事件
自定义事件参数参考http://topic.csdn.net/u/20090218/16/18d574da-71ba-42f3-88fe-821b68fb32de.html
[解决办法]
on Button_OnClick
on text_change