Skip to content

Instantly share code, notes, and snippets.

@masaru-b-cl
Created December 21, 2011 06:34
Show Gist options
  • Save masaru-b-cl/1504914 to your computer and use it in GitHub Desktop.
Save masaru-b-cl/1504914 to your computer and use it in GitHub Desktop.
ItemCommand Event Test
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
FormView1.DataSource = new[] { new { MyCode = "0001" } };
Page.DataBind();
}
protected void FormView1_ItemCommand(object sender, FormViewCommandEventArgs e)
{
Label1.Text += "Hello ";
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FormView ID="FormView1" runat="server"
onitemcommand="FormView1_ItemCommand">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>
<asp:Button ID="Button1" runat="server" Text="Button" />
</ItemTemplate>
</asp:FormView>
<asp:Label ID="Label1" runat="server"></asp:Label>
</div>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment