Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# gridview更新/插入列_C#_Asp.net - Fatal编程技术网

C# gridview更新/插入列

C# gridview更新/插入列,c#,asp.net,C#,Asp.net,我正在编辑和更新gridview列,但它不接受这些值。它不会显示错误 请告诉我这个建议。如何做更新。如果是am,请单击编辑并启用。当am输入值时,它不会更新数据库 if (ViewState["LeaveManagementID"] == null) { foreach (GridViewRow row in gvLeaves.Rows) { EP_LeaveManage

我正在编辑和更新gridview列,但它不接受这些值。它不会显示错误

请告诉我这个建议。如何做更新。如果是am,请单击编辑并启用。当am输入值时,它不会更新数据库

if (ViewState["LeaveManagementID"] == null)

        {

                foreach (GridViewRow row in gvLeaves.Rows)
                {

                    EP_LeaveManagementRow leaveUpdateRow = db.EP_LeaveManagementCollection.GetRow("LeaveManagementID=" + gvLeaves.DataKeys[e.RowIndex].Value);

                    if (leaveUpdateRow != null)
                    {
                        leaveUpdateRow.NoOfDays = int.Parse(lblNoOfDays.Text.ToString());


                        db.EP_LeaveManagementCollection.Update(leaveUpdateRow);
                        ViewState["LeaveManagementID"] = leaveUpdateRow.LeaveManagementID;

                        mvLeaveManagement.SetActiveView(vwLeavesDetails);
ASPX



你可以在谷歌上找到很多例子,这是其中之一。这是你的解决方案,如果你想使用GridView在数据库中插入、删除和更新数据,请点击以下链接:-
   <asp:TemplateField HeaderText="Comments">
                                            <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle"></ItemStyle>
                                            <HeaderStyle Width="15%" HorizontalAlign="Left" VerticalAlign="Middle"></HeaderStyle>
                                             <ItemTemplate>
                                                        <asp:Label ID="lblComments" Visible="false" runat="server" ></asp:Label>

                                                    </ItemTemplate>
                                            <EditItemTemplate>
                                            <asp:TextBox ID="txtComments" runat="server" MaxLength="50" TextMode="MultiLine"  Text='<%#Bind("LeaveCommants") %>'></asp:TextBox>
                                            </EditItemTemplate>

                                        </asp:TemplateField>


 <asp:TemplateField HeaderText="Edit/Update" HeaderStyle-Width="25%">
                                                <ItemTemplate>

                                                    <asp:LinkButton ID="lkbEdit" Text="Edit" runat="server" CommandName="Edit"  />
                                                    <%-- <asp:LinkButton ID="lkbUpdate" Text="Update" runat="server" CommandName="Update"  />--%>


                                                </ItemTemplate>
                                               <EditItemTemplate>

                                                    <asp:LinkButton ID="btnUpdate" Text="Update" runat="server" CommandName="Update" />
                                                    <asp:LinkButton ID="btnCancel" Text="Cancel" runat="server" CommandName="Cancel" />

                                                </EditItemTemplate>
                                            </asp:TemplateField>