在网格视图中输入关键文本框行未获取ID选择

问题描述 投票:0回答:1

我希望在单元格中输入填充数据之后编辑gridview中第4列的数据保存我只能保存第一行,同时这样做。

请帮助我,我试着尝试每一个建议。

function controlEnter(obj, event) {
        var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
        if (keyCode == 13) {
            var time = $('[id*=txtdateN]').val();
            var row = $(this).closest("tr");
            var KULNid = $('[id*=txtID]').val();
            var Grid_EnterKey = document.getElementById(obj);
            var gKANRIZU_NO = obj;   
            var gSOK1 = $(this).closest('tr').find('.SOK1').val();
            var gSOK2 = $(this).closest('tr').find('.SOK2').val();
            var gSOK3 = $(this).closest('tr').find('.SOK3').val();
            var gSOK4 = $(this).closest('tr').find('.SOK4').val();
            $.ajax({
                type: "POST",
                url: "WebService.asmx/UpdategridG",
                data: "{'KULN' :'" + KULNid + "', 'KANRIZU_NO': '" + gKANRIZU_NO + "' ,'SOK1': '" + gSOK1 + "' , 'SOK2': '" + gSOK2 + "' , 'SOK3': '" + gSOK3 + "', 'SOK4' : '" + gSOK4 + "','time' : '" + time + "' }",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                error: OnErrorCall_
            });

            function OnErrorCall_(repo) {

                alert("Something went wrong, pls check setting");
            }
        }
        else {
            return true;
        }
    }
    </script>
<asp:TemplateField HeaderText="SOK1" HeaderStyle-CssClass="text-center" ItemStyle-BackColor="#f4f7c9">
                        <ItemTemplate>
                            <asp:Label ID="lblSOK1" runat="server"></asp:Label>
                            <asp:TextBox ID="txtSOK1" ReadOnly="false" runat="server" CssClass="SOK1 hideControl form-control"></asp:TextBox> 
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txt01" ReadOnly="false" runat="server"></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="SOK2" HeaderStyle-CssClass="text-center" ItemStyle-BackColor="#f4f7c9">
                        <ItemTemplate>
                            <asp:Label ID="lblSOK2" runat="server"></asp:Label>
                            <asp:TextBox ID="txtSOK2" ReadOnly="false" runat="server" CssClass="SOK2 hideControl form-control"></asp:TextBox>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txt02" ReadOnly="false" runat="server"></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="SOK3" HeaderStyle-CssClass="text-center" ItemStyle-BackColor="#f4f7c9">
                        <ItemTemplate>
                            <asp:Label ID="lblSOK3" runat="server"></asp:Label>
                            <asp:TextBox ID="txtSOK3" ReadOnly="false" runat="server" CssClass="SOK3 hideControl form-control"></asp:TextBox>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txt03" ReadOnly="false" runat="server"></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="SOK4" HeaderStyle-CssClass="text-center" ItemStyle-BackColor="#f4f7c9">
                        <ItemTemplate>
                            <asp:Label ID="lblSOK4" runat="server"></asp:Label>
                            <asp:TextBox ID="txtSOK4" runat="server" CssClass="SOK4 hideControl form-control"></asp:TextBox>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txt04" runat="server"></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
javascript c# ajax gridview
1个回答
0
投票

只需传递要更新的所选列的ClientID的唯一ID,并通过ClientID更新数据库行

在ajax

data: {'ClientID': ClientID, 'others parames'},

例如

$sql = "updated table set column1=value Where ClientID=20";

我希望这能帮到您

© www.soinside.com 2019 - 2024. All rights reserved.