0

(SAPUserID ,SAPDescription,SAPPassword,OSUserID,OSDescription,OSPassword)6 つの列とCHANGE PASSWORDボタンを持つグリッドビューが あります。pnlChangePwdこのボタンをクリックすると、グリッド ビューの下のパネル ( ) が表示され、3 つ(User ID, New Password, Confirm Password)のテキスト ボックスとボタンが表示Saveされます。txtNewPasswordグリッド ビューで値を SAPPassword または OSPassword のセル値と比較する方法は?

注: ユーザーが必要とするデータ (SAP または OS) に応じて、一度に 3 つの列のみが表示されます。

グリッド ビューのコード:

<asp:GridView runat="server" ID="gvPassInfo" AutoGenerateColumns="false" 
                          CellPadding="4" ForeColor="#333333" GridLines="Both" DataKeyNames="user_id" 
                          CssClass="Gridview"  OnRowEditing="gvPassInfo_RowEditing"
                          OnRowCommand="gvPassInfo_RowCommand"  OnRowDataBound="gvPassInfo_RowDataBound">
                <RowStyle BackColor="#EFF3FB" />
                <Columns>                                       
                    <asp:TemplateField HeaderText="User ID" Visible="false">
                        <ItemTemplate>
                            <asp:Label ID="lblSAPUserId" runat="server">
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="User ID" Visible="false">
                        <ItemTemplate>
                            <asp:Label ID="lblOSUserId" runat="server">
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="Description" Visible="false">
                        <ItemTemplate>
                            <asp:Label ID="lblSAPDescription" runat="server">
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="Description" Visible="false">
                        <ItemTemplate>
                            <asp:Label ID="lblOSDescription" runat="server">
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="Password" Visible="false">
                        <ItemTemplate>
                            <asp:Label ID="lblSAPPassword" runat="server">
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="Password" Visible="false">
                        <ItemTemplate>
                            <asp:Label ID="lblOSPassword" runat="server">
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="Change Password">
                        <ItemTemplate>
                            <asp:ImageButton ID="ImgBtnChangePass" runat="server" ImageUrl="~/images/PW.jpg" CausesValidation="false"
                                             CommandName="Edit" />
                        </ItemTemplate>
                    </asp:TemplateField>


                </Columns>
                <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <EditRowStyle BackColor="#2461BF" />
                <AlternatingRowStyle BackColor="White" />
            </asp:GridView>
4

1 に答える 1

0

保存ボタンのコードは次のとおりです。

    var currentRow = gvPassInfo.Rows.OfType<GridViewRow>().Single(r => ((Label)r.FindControl("lblSAPUserId")).Text == txtUserId.Text);
    bool doesMatch = ((Label)currentRow.FindControl("lblOSPassword")).Text == "NewPassword";

ただし、グリッドにバインドしているコレクションでパスワードを検索することをお勧めします。

于 2012-06-07T10:03:26.043 に答える