select() is an existing method name, try selectObj()
<%@ Page Debug="true" %>
<%@ Import Namespace="System.Data" %>
<html>
<script language="C#" runat="server">
void Page_Load(Object sender, EventArgs e)
{
if (!IsPostBack)
{
MyDataGrid.DataSource = new string[] {"a","b","c"};
MyDataGrid.DataBind();
}
}
</script>
<body>
<h3><font face="Verdana">Specifying Columns in DataGrid</font></h3>
<form runat=server>
<ASP:DataGrid id="MyDataGrid" runat="server"
AutoGenerateColumns="false">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:TextBox id="txt" Runat="server" Text='<%# Container.DataItem%>'/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox id="select" Runat="server" Checked="False" οnclick="selectObj(this)"> </asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
<asp:Button Text="Click Me" runat="server"/>
</form>
</body>
</html>
<script language="javascript">
function selectObj(obj)
{
alert(obj.checked);
if (obj.checked) //是否被选中
{
//...
}
var p = obj.parentElement;
while (p.tagName != "TR")
p = p.parentElement;
var inputs = p.all.tags("INPUT");
for (var i=0; i < inputs.length; i++)
alert(inputs[i].value);
}
</script>