本文介绍了如何在嵌套网格行命令中获取下拉列表的选定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在嵌套Gridview行命令上更改DropDownList的值后新OR。



I want to new OR after changed value of DropDownList on Nested Gridview rowcommand..

<asp:GridView ID="grid" EmptyDataText="No receipt book(s) found.!" runat="server"

        OnRowDataBound="grid_rowdatabound">
        <Columns>
            <%--SrNo--%>
            <asp:TemplateField HeaderText="No." HeaderStyle-Width="18px">
                <ItemTemplate>
                    <%# Container.DataItemIndex + 1 %>
                </ItemTemplate>
                <ItemStyle VerticalAlign="Middle" HorizontalAlign="Center" />
            </asp:TemplateField>
            <asp:TemplateField>
                <ItemTemplate>
                    <img alt="" style="cursor: pointer;" src="../images/plus.png" />
                    <asp:Panel ID="pnlChiled"  runat="server"

                        Style="display: none;" Width="800px">
                        <asp:GridView ID="gvReceipts" runat="server" AutoGenerateColumns="false" CssClass="gridview"

                            Width="500px" OnRowCommand="gridReceiptCopy_onRowcommand">
                            <HeaderStyle CssClass="gridviewHeader" />
                            <Columns>
                                <asp:TemplateField HeaderText="No." HeaderStyle-Width="18px">
                                    <ItemTemplate>
                                        <asp:Label ID="lblNo" runat="server" Text='<%#Eval("Number")%>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Status" HeaderStyle-Width="50px" ItemStyle-Width="50px">
                                    <ItemTemplate>
                                        <asp:DropDownList ID="ddlReceiptCopyStatus" runat="server">
                                            <asp:ListItem Text="firstValue" Value="1"></asp:ListItem>
                                            <asp:ListItem Text="secondValue" Value="2"></asp:ListItem>
                                        </asp:DropDownList>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lbtnSubmit" runat="server" CssClass="buttonfcr" CommandName="ChangeCopyStatus"

                                            Text="Submit"></asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                    </asp:Panel>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>





我的代码在.cs文件或Onrowcommand事件中



My code inside .cs file or Onrowcommand event

protected void gridReceiptCopy_onRowcommand(object sender, GridViewCommandEventArgs e)
      {
          if (e.CommandName.Equals("ChangeCopyStatus"))
          {
              GridViewRow curruntRow = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);

              DropDownList ddlCopyStatus = (DropDownList)curruntRow.FindControl("ddlReceiptCopyStatus") as DropDownList;//copystatus dropdownlist
              string selectedNewValue = ddlCopyStatus.SelectedItem.Text;
              //here i want to get the selectedValue
          }
      }



但是我得到了我在gridBind分配的默认下拉列表..

请帮助我..

提前感谢..


But i get the by default of dropdownlist that i assign at gridBind..
please help me..
thanks in advance..

推荐答案


这篇关于如何在嵌套网格行命令中获取下拉列表的选定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 05:50