[英]Add an onClick to an Infragistics WebDataGrid
I have an Infragistics WebDataGrid and I want to fire a server side event every time a cell is clicked on. 我有一个Infragistics WebDataGrid,我想每次单击一个单元格时都触发一个服务器端事件。 I know that I can make a button and add an onclick to that, but I want some or all the data cells to be clickable. 我知道我可以创建一个按钮并向其中添加一个onclick,但是我希望某些或所有数据单元都是可单击的。 I also saw this( https://www.infragistics.com/community/forums/f/ultimate-ui-for-asp-net/108226/onclick-event-for-webdatagrid ) but I need the event to fire server side. 我也看到了这个( https://www.infragistics.com/community/forums/f/ultimate-ui-for-asp-net/108226/onclick-event-for-webdatagrid ),但是我需要事件来触发服务器端。
You can try the following: 您可以尝试以下方法:
The Grid is very powerful control with a rich API and the behaviors, so we could thing of a different way to achieve this. Grid是一个非常强大的控件,具有丰富的API和行为,因此我们可以采用另一种方式来实现这一目标。
Snippet: 片段:
..
<script>
function client_click(sender, evtArgs) {
// First Approach
__doPostBack('myRequest', "someValue");
}
function WDG_Selection_CellSelectionChanged(sender, eventArgs)
{
// Second Approach
__doPostBack('myRequest', "someValue");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" ID="ScriptManager1"></asp:ScriptManager>
<div>
<ig:WebDataGrid runat="server" ID="WDG" AutoGenerateColumns="False" Width="600px">
<ClientEvents Click="client_click" />
<Columns>
<ig:BoundDataField DataFieldName="CategoryId" Key="CategoryId">
<Header Text="CategoryId">
</Header>
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="CategoryName" Key="CategoryName">
<Header Text="CategoryName">
</Header>
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="Description" Key="Description">
<Header Text="Description">
</Header>
</ig:BoundDataField>
</Columns>
<Behaviors>
<ig:EditingCore>
<Behaviors>
<ig:CellEditing>
<CellEditingClientEvents EnteringEditMode="entering_edit_mode" />
</ig:CellEditing>
</Behaviors>
</ig:EditingCore>
<ig:Selection>
<SelectionClientEvents CellSelectionChanged="WDG_Selection_CellSelectionChanged" />
</ig:Selection>
</Behaviors>
</ig:WebDataGrid>
..
c# C#
protected void Page_Load(object sender, EventArgs e)
{
string parameter = Request["__EVENTARGUMENT"];
... ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.