在datagrid的模板列下
...
<asp:TemplateColumn HeaderText="退">
<ItemTemplate>
<asp:CheckBox runat=server ID="chk" Checked='<%# container.dataitem("chk") %>' Width=6px onclick="ca(1)" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="實領數">
<ItemTemplate>
<asp:TextBox Runat="server" ID="qty" Text='<%# container.dataitem("qty") %>' Width=80px style="TEXT-ALIGN: right " Font-Name="新細明體" Font-size="9pt" onkeypress="ck(4,4)" onchange="ca(2);">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
...
function ca(i)
{
var e = event.srcElement;
var row;
if (i==2)
{row= e.parentNode.parentNode;}//錄入實領數時
else
{row= e.parentNode.parentNode.parentNode;}//勾選退料時,要不然則值為undefined,其原因是它在<tr><td><span><input type=checkbox...></span></td></tr>
var txts = row.all.tags("INPUT");
var sels = row.all.tags("SELECT");
...
}
...
<asp:TemplateColumn HeaderText="退">
<ItemTemplate>
<asp:CheckBox runat=server ID="chk" Checked='<%# container.dataitem("chk") %>' Width=6px onclick="ca(1)" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="實領數">
<ItemTemplate>
<asp:TextBox Runat="server" ID="qty" Text='<%# container.dataitem("qty") %>' Width=80px style="TEXT-ALIGN: right " Font-Name="新細明體" Font-size="9pt" onkeypress="ck(4,4)" onchange="ca(2);">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
...
function ca(i)
{
var e = event.srcElement;
var row;
if (i==2)
{row= e.parentNode.parentNode;}//錄入實領數時
else
{row= e.parentNode.parentNode.parentNode;}//勾選退料時,要不然則值為undefined,其原因是它在<tr><td><span><input type=checkbox...></span></td></tr>
var txts = row.all.tags("INPUT");
var sels = row.all.tags("SELECT");
...
}