I have a GridView with ItemTemplate( Checkbox and TextBox )
<asp:GridView ID="gvNonTimeCard" runat="server">
<asp:TemplateField HeaderText="Delete?">
<ItemTemplate>
<asp:CheckBox ID="chkDelete" runat="server" onclick="return chkDelete_OnClick(this);"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date" >
<ItemTemplate>
<asp:TextBox runat="server" ID="txtDate" CssClass="Width_2" format="Date" Text='<%# DataBinder.Eval(Container, "DataItem.DateWorked") %>' Description="Date on row ">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</asp:GridView>
I have written a JavaScript function to find a texDate value on click checkbox. But i dont' see get any value its returning control id "gvNonTimeCard_ctl03_txtDate"?
function chkDelete_OnClick(objCheckbox) {
if (objCheckbox != null) {
console.log("objCheckBox null");
var val = document.getElementById(objCheckbox.id.replace("chkDelete", "txtDate")).id;
}
在您的代码中替换此行
var val = document.getElementById(objCheckbox.id.replace("chkDelete", "txtDate")).value;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.