BasicGridView继承自GridView,并为其添加了一个ActionTemplate,里面放一下按钮并让其和翻页一起绘制在gridview的底部.如此调用:
<sgc:BasicGridView ID="gridView" runat="server" AllowSorting="True" AllowPaging="True" AutoGenerateColumns="false" DataKeyNames="Id" OnActionCommand="gridview_ActionCommand" >
<Columns>
<asp:BoundField DataField="Name" HeaderText="<%$Resources:Resource,Name%>" SortExpression="Name" />
<asp:BoundField DataField="Description" HeaderText="<%$Resources:Resource,Description%>" SortExpression="Description" />
</Columns>
<ActionTemplate>
<asp:LinkButton ID="btnAdd" runat="server" commandname="add">LinkButton</asp:LinkButton>
</ActionTemplate>
</sgc:BasicGridView>为处理ActionTemplate中的事件:
在BasicGridView中添加了如下代码: [
Browsable(false),
DefaultValue(null),
Description("The action controls template."),
TemplateContainer(typeof(ActionTemplateContainer)),
PersistenceMode(PersistenceMode.InnerProperty)
]
public ITemplate ActionTemplate
{
get { return this._actionTemplate; }
set { this._actionTemplate = value; }
} protected override void RaisePostBackEvent(string eventArgument)
{
if (eventArgument.StartsWith("Action$"))
{
OnActionCommand(new CommandEventArgs(eventArgument.Substring(eventArgument.IndexOf("$")+1), eventArgument));
return;
}
base.RaisePostBackEvent(eventArgument);
}
private static readonly object EventActionCommand = new object(); public event CommandEventHandler ActionCommand
{
add { Events.AddHandler(EventActionCommand, value); }
remove { Events.RemoveHandler(EventActionCommand, value); }
} public virtual void OnActionCommand(CommandEventArgs e)
{
CommandEventHandler commandHandler = (CommandEventHandler)Events[EventActionCommand];
if (commandHandler != null)
commandHandler(this, e);
}btnAdd客户端产生的代码是
<a id="gridview_btnAdd" href="javascript:__doPostBack(gridview$btnAdd','')">LinkButton</a>我希望btnAdd的客户端代码是
<a id="gridview_btnAdd" href="javascript:__doPostBack(gridview$btnAdd','Action$add')">LinkButton</a>
以便处理
请问这个该如何实现
或者有什么好的其他方法实现类似的功能(及为gridview添加自定义template并处理其内部控件的事件)
请高手指点,谢谢!!!!
<sgc:BasicGridView ID="gridView" runat="server" AllowSorting="True" AllowPaging="True" AutoGenerateColumns="false" DataKeyNames="Id" OnActionCommand="gridview_ActionCommand" >
<Columns>
<asp:BoundField DataField="Name" HeaderText="<%$Resources:Resource,Name%>" SortExpression="Name" />
<asp:BoundField DataField="Description" HeaderText="<%$Resources:Resource,Description%>" SortExpression="Description" />
</Columns>
<ActionTemplate>
<asp:LinkButton ID="btnAdd" runat="server" commandname="add">LinkButton</asp:LinkButton>
</ActionTemplate>
</sgc:BasicGridView>为处理ActionTemplate中的事件:
在BasicGridView中添加了如下代码: [
Browsable(false),
DefaultValue(null),
Description("The action controls template."),
TemplateContainer(typeof(ActionTemplateContainer)),
PersistenceMode(PersistenceMode.InnerProperty)
]
public ITemplate ActionTemplate
{
get { return this._actionTemplate; }
set { this._actionTemplate = value; }
} protected override void RaisePostBackEvent(string eventArgument)
{
if (eventArgument.StartsWith("Action$"))
{
OnActionCommand(new CommandEventArgs(eventArgument.Substring(eventArgument.IndexOf("$")+1), eventArgument));
return;
}
base.RaisePostBackEvent(eventArgument);
}
private static readonly object EventActionCommand = new object(); public event CommandEventHandler ActionCommand
{
add { Events.AddHandler(EventActionCommand, value); }
remove { Events.RemoveHandler(EventActionCommand, value); }
} public virtual void OnActionCommand(CommandEventArgs e)
{
CommandEventHandler commandHandler = (CommandEventHandler)Events[EventActionCommand];
if (commandHandler != null)
commandHandler(this, e);
}btnAdd客户端产生的代码是
<a id="gridview_btnAdd" href="javascript:__doPostBack(gridview$btnAdd','')">LinkButton</a>我希望btnAdd的客户端代码是
<a id="gridview_btnAdd" href="javascript:__doPostBack(gridview$btnAdd','Action$add')">LinkButton</a>
以便处理
请问这个该如何实现
或者有什么好的其他方法实现类似的功能(及为gridview添加自定义template并处理其内部控件的事件)
请高手指点,谢谢!!!!
那如果要实现类似的功能该如何实现?
复合控件似乎实现不了LinkButton得个数不确定把