Click here to Skip to main content
15,890,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to new OR after changed value of DropDownList on Nested Gridview rowcommand..

ASP.NET
<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>


My code inside .cs file or Onrowcommand event
C#
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
          }
      }

But i get the by default of dropdownlist that i assign at gridBind..
please help me..
thanks in advance..
Posted
Updated 6-Jul-13 19:44pm
v4

1 solution

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.SelectedValue;
//here i want to get the selectedValue
}
}
 
Share this answer
 
Comments
Member 9741359 11-Feb-15 4:50am    
Hi!
Do you get the solution for this problem? I am also facing this problem.
[no name] 11-Feb-15 6:02am    
hello,
no, i not get solution but my dropdownlist value was fix so i replace control from dropdownlist to asp:radioButton and i get selected radio button checked value and my problam is resolved.

thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900