0

按下带有gridview的更新按钮时,如何从文本框中获取字符串?

在此处输入图像描述

当我按下更新按钮时,我想检索每个文本框中的字符串,如上所示。我如何实现这一目标?我需要它们在我的 SQL UPDATE 中作为参数传递。

我的 gridview 具有以下内容,我认为这是按下更新时的火灾:

OnRowUpdating="viewStoryTime_OnRowUpdating"

以及包含获取字符串的代码的方法:

protected void viewStoryTime_OnRowUpdating(object sender, GridViewUpdateEventArgs e)
{
   //get strings from textboxes
}

编辑,这是完整的网格视图:

                    <asp:GridView ID="viewStoryTime" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                        DataSourceID="SqlDataSource10" DataKeyNames="NonScrumStoryId, PK_DailyTaskHours" BackColor="#DEBA84"
                        BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2"
                        Width="525px" OnRowEditing="viewStoryTime_OnRowEditing" OnRowCancelingEdit="viewStoryTime_OnRowCancelingEdit" OnRowUpdating="viewStoryTime_OnRowUpdating" >
                        <Columns>
                            <asp:BoundField DataField="Hours" HeaderText="Hours" SortExpression="Hours" />
                            <asp:BoundField DataField="Notes" HeaderText="Notes" SortExpression="Notes" />
                            <asp:BoundField DataField="ActivityDate" HeaderText="Date" SortExpression="ActivityDate"
                                DataFormatString="{0:MM/dd/yyyy}" />
                            <asp:CommandField ShowEditButton="True" />
                        </Columns>
                        <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
                        <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
                        <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
                        <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
                        <SortedAscendingCellStyle BackColor="#FFF1D4" />
                        <SortedAscendingHeaderStyle BackColor="#B95C30" />
                        <SortedDescendingCellStyle BackColor="#F1E5CE" />
                        <SortedDescendingHeaderStyle BackColor="#93451F" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="SqlDataSource10" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                        SelectCommand="SELECT [DailyTaskHours].[PK_DailyTaskHours], [DailyTaskHours].[NonScrumStoryId], [DailyTaskHours].[Hours], [DailyTaskHours].[Notes], [DailyTaskHours].[ActivityDate] FROM [NonScrumStory], [DailyTaskHours] WHERE [DailyTaskHours].[NonScrumStoryId] = @nonScrumStoryId AND [NonScrumStory].[PK_NonScrumStory] = @nonScrumStoryId"
                        UpdateCommand="UPDATE [DailyTaskHours] SET [Hours] = @setEditHoursParam, [ActivityDate] = @setEditActivityDateParam, [Notes] = @setEditNotesParam WHERE [PK_DailyTaskHours] = @setDailyPKParam">
                        <SelectParameters>
                            <asp:QueryStringParameter Name="nonScrumStoryId" Type="String" />
                        </SelectParameters>
                        <UpdateParameters>
                            <asp:QueryStringParameter Name="setEditHoursParam" Type="String" />
                            <asp:QueryStringParameter Name="setEditActivityDateParam" Type="String" />
                            <asp:QueryStringParameter Name="setEditNotesParam" Type="String" />
                            <asp:QueryStringParameter Name="setDailyPKParam" Type="String" />
                        </UpdateParameters>
                    </asp:SqlDataSource>
4

0 回答 0