ami k

ami k

  • NA
  • 2
  • 4.1k

grid view and dropdownlist

Sep 17 2012 8:16 AM
hi,
i added one dropdownlist in the edit mode of gridview , but i cannot read the selected value in the code behind page, i set the auto post back as true, still am not getting...
can anybody pls help.. its very urgent...

my code in aspx is 

<asp:GridView runat="server" ID="GridView_Subscription"
            AutoGenerateColumns="False" Width="681px"  RowStyle-HorizontalAlign="Left" 
            RowStyle-VerticalAlign="Middle" RowStyle-Height="2em" AllowPaging="True" 
            AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines="None" 
            onpageindexchanging="GridView_Subscription_PageIndexChanging" 
            onrowediting="GridView_Subscription_RowEditing"
            onrowcancelingedit="GridView_Subscription_RowCancelingEdit" 
            onrowdeleting="GridView_Subscription_RowDeleting" 
            onrowupdating="GridView_Subscription_RowUpdating" >
       
       <Columns>
            <asp:BoundField DataField="CONFIG_ID" HeaderText="ID" Visible="false"/>  
            <asp:BoundField DataField="SRC_TYPE" HeaderText="SOURCE TYPE"/>
            <asp:BoundField DataField="ITEM_TITLE" HeaderText="SOURCE"/>
            <asp:BoundField DataField="ITEM_URL" HeaderText="SUBSCRIPTION DETAILS" />


            <asp:TemplateField HeaderText="FREQUENCY">
                <EditItemTemplate>
                    <asp:DropDownList runat="server" ID="DropDown_frequency"  >
                    <%--<asp:ListItem Text="Hourly" Value="0"></asp:ListItem>
                    <asp:ListItem Text="Daily" Value="1"></asp:ListItem>
                    <asp:ListItem Text="Weekly" Value="2"></asp:ListItem>
                    <asp:ListItem Text="Monthly" Value="3"></asp:ListItem>--%>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblFreq" runat="server" Text='<%# Bind("FREQUENCY") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:CommandField ShowEditButton="True" CausesValidation="false" />
            <asp:TemplateField ShowHeader="False">
            <ItemTemplate>
                 <asp:LinkButton ID="btndelete" runat="server" CausesValidation="False" 
                        CommandName="Delete" Text="Delete"
                        OnClientClick="return confirm('Are you sure you want to delete this?')"></asp:LinkButton>
            </ItemTemplate>
            </asp:TemplateField>
            </Columns>
            <EditRowStyle BackColor="#999999" />
            <FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="white" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#E9E7E2" />
            <SortedAscendingHeaderStyle BackColor="#506C8C" />
            <SortedDescendingCellStyle BackColor="#FFFDF8" />
            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
    </asp:GridView>

and in the code behind is 

DropDownList ddl = (DropDownList)GridView_Subscription.Rows[e.RowIndex].FindControl("Freq_Combo");
            string text = ddl.SelectedItem.Text;


am populating the dropdown from code behind.

thanks in advance






Answers (2)