Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DropDown list in datagrid loses values of the row selected

Posted on 2011-02-11
10
Medium Priority
?
617 Views
Last Modified: 2012-05-11
I have a drop down list in a datagrid, when the user selects a value, and the grid is rebinded I lose the value selected.

Would like to know How to keep the value of the dropdown that the user selected.
I am also using AJAX and the datagrid is inside an update panel
0
Comment
Question by:countrymeister
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 11

Accepted Solution

by:
rajvja earned 668 total points
ID: 34868847
Hi

Check whether the AutoPostBack is set. It should be false
0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 668 total points
ID: 34868849
have you checked the Ispostback condition in Page_load before binding data to Grid?

can you share page_load code
0
 
LVL 1

Author Comment

by:countrymeister
ID: 34868876
Yes, I have checked the Postback condition and my dropdown list has AutoPostBack = false
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:rajvja
ID: 34868963
Hi,

   Then, you need to check you BindGrid code.

It should be in
    If Not Page.IsPOstBak then
      'bind grid
    End if
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 664 total points
ID: 34869665
You need to save the selection before you rebind the grid.
0
 
LVL 1

Author Comment

by:countrymeister
ID: 34870030
CodeCruiser
How do  I do that? Anycode  examples will be helpful
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34870057
Do you have code setup to save gridview back to the DB?
0
 
LVL 1

Author Comment

by:countrymeister
ID: 34870167
Codecruiser, I have pasted my datagrid set up, I have an itemDatbound which binds the dropdown list with the values I get from the db.

My issue is how to save the changed values on the dropdown.
I cannot triger an OnSelectedIndex change on the dropdown since it is embedded in the grid, can I ?
<asp:DataGrid ID="dgItemSelect" runat="server" AutoGenerateColumns="false" ShowHeader="false" ShowFooter="false" 
    CellPadding="1" CellSpacing="0" CssClass="DataTable" EnableViewState="true">
    <Columns>
        <asp:TemplateColumn>                                    
            <ItemStyle CssClass="RowButton" HorizontalAlign="Center"  />
            <ItemTemplate>
                <asp:ImageButton ImageUrl="~/images/delete.png"  Height="16" Width="16" ToolTip="Remove Row" Text="X" ID="btnDeleteRow" runat="server" CommandName="DeleteCurrentRow"  />
            </ItemTemplate>
            
        </asp:TemplateColumn>
        <asp:TemplateColumn>
            <ItemStyle/>
            <ItemTemplate>
                <asp:TextBox borderstyle="None" Width="100px" ID="txtItemCode" runat="server"></asp:TextBox><asp:DropDownList Width="200px" ID="ddlSpecimens"  Visible="false" runat="server"></asp:DropDownList>
            </ItemTemplate>
            
        </asp:TemplateColumn>
        <asp:TemplateColumn>
            <ItemStyle  />
            <ItemTemplate>
                <asp:TextBox ReadOnly="true" Width="250px" BorderStyle="None" ID="txtDescription" runat="server"></asp:TextBox>
            </ItemTemplate>            
        </asp:TemplateColumn>
        <asp:TemplateColumn>
            <ItemStyle  />
            <ItemTemplate>
                <asp:DropDownList Width="120px" ID="ddlFrequency" runat="server"   AutoPostBack="false">
                 <asp:ListItem Text="" Value=""></asp:ListItem>
						  <asp:ListItem Text="MWF" Value="M-W-F"></asp:ListItem>
						  <asp:ListItem Text="MF" Value="M-F"></asp:ListItem>
						  <asp:ListItem Text="TTH" Value="T-TH"></asp:ListItem>						  
						  <asp:ListItem Text="TTHS" Value="T-TH-S"></asp:ListItem>
						  <asp:ListItem Text="Daily" Value="Daily"></asp:ListItem>
						  <asp:ListItem Text="Weekly" Value="Weekly"></asp:ListItem>
						  <asp:ListItem Text="Bi-Weekly" Value="B1-Weekly"></asp:ListItem>
						  <asp:ListItem Text="Monthly" Value="Monthly"></asp:ListItem>
						  <asp:ListItem Text="Bi-Monthly" Value="Bi-Monthly"></asp:ListItem>
						  <asp:ListItem Text="Quarterly" Value="Quarterly"></asp:ListItem>
						  <asp:ListItem Text="Yearly" Value="Yearly"></asp:ListItem>
                </asp:DropDownList>
                <asp:Label ID="lblFrequency" runat="server" Visible="false"></asp:Label>&nbsp;&nbsp;&nbsp;
            </ItemTemplate>            
        </asp:TemplateColumn>
         <asp:TemplateColumn>
            <ItemStyle  />
            <ItemTemplate>
                <asp:DropDownList Width="100px" ID="ddlDiagnosticCodes" runat="server" DataValueField="DiagnosticCode" DataTextField="DiagnosticCode"  ></asp:DropDownList>
                <asp:Label ID="lblDiagnostic" runat="server" Visible="false"></asp:Label>
            </ItemTemplate>            
        </asp:TemplateColumn>
    </Columns>     
</asp:DataGrid>

Open in new window

0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34870187
Is the grid unbound?
0
 
LVL 1

Author Comment

by:countrymeister
ID: 34943361
The grid is bound in code behind
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question