Advertisement

10.15.2007 at 07:55AM PDT, ID: 22893706
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.4

Datagrid Item.ItemIndex is pulling the next row instead of the correct row

Asked by blouckswwu in C# Programming Language, Programming for ASP.NET

Tags: , ,

I am creating a custom web application for our online portal.  I am using C# to code this application and I am having a problem with my data grid.  I can get the data to display on the datagrid, but when I select the edit command the value (Student ID Number) is one off.  For example if I select the first item on the datagrid to edit and pulls the key information of the next one down on the datagrid.

Here is the datagrid code.  Please note that the groupedgrid is a custom function using the datagrid that was developed by our online portal product developer but uses the same properties:

      <common:groupedgrid id="grdSearchResults" RenderGroupHeaders="True" runat="server" GridLines="None"
            HeaderRightColumns="(Collection)" allowsorting="True" allowpaging="True" PagerStyle-Mode="NumericPages"
            PagerStyle-HorizontalAlign="Right" RenderTableFooters="True" ShowFooter="True" DataKeyField="ID_NUM">
            <Columns>
                  <common:EditButtonColumn ToolTipKey="" TextKey="" HeaderText="View"></common:EditButtonColumn>
                  <asp:TemplateColumn SortExpression="NM.ID_NUM" HeaderText="ID Number">
                        <ItemTemplate>
                              <%# DataBinder.Eval(Container.DataItem,"ID_NUM") %>
                        </ItemTemplate>
                  </asp:TemplateColumn>
                  <asp:TemplateColumn SortExpression="NM.FIRST_NAME" HeaderText="First Name">
                        <ItemTemplate>
                              <%# DataBinder.Eval(Container.DataItem,"FIRST_NAME") %>
                        </ItemTemplate>
                  </asp:TemplateColumn>
                  <asp:TemplateColumn SortExpression="NM.LAST_NAME" HeaderText="Last Name">
                        <ItemTemplate>
                              <%# DataBinder.Eval(Container.DataItem,"LAST_NAME") %>
                        </ItemTemplate>
                  </asp:TemplateColumn>
                  <asp:TemplateColumn HeaderText="DOB">
                        <ItemTemplate>
                              <%# DataBinder.Eval(Container.DataItem,"DOB") %>
                        </ItemTemplate>
                  </asp:TemplateColumn>
                  <asp:TemplateColumn SortExpression="BM.GENDER" HeaderText="Gender">
                        <ItemTemplate>
                              <%# DataBinder.Eval(Container.DataItem,"GENDER") %>
                        </ItemTemplate>
                  </asp:TemplateColumn>
            </Columns>
            <PagerStyle HorizontalAlign="Right" Mode="NumericPages"></PagerStyle>
      </common:groupedgrid>

Here is the code behind for the edit function:

            private void grdSearchResults_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
            {
                  this.ParentPortlet.PortletViewState["ID_NUM"] = grdSearchResults.DataKeys[e.Item.ItemIndex].ToString();
                  //Label1.Text = grdSearchResults.DataKeys[e.Item.ItemIndex].ToString();
                  //Response.Write(grdSearchResults.DataKeys[e.Item.ItemIndex]);
                  
                  this.ParentPortlet.NextScreen("Student_Detail");

I have used this method in the past and it has worked perfectly.

Thanks for any assistance!

BillStart Free Trial
 
Loading Advertisement...
 
[+][-]10.16.2007 at 08:12AM PDT, ID: 20086241

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C# Programming Language, Programming for ASP.NET
Tags: datagrid, next, row
Sign Up Now!
Solution Provided By: AshleyBryant
Participating Experts: 1
Solution Grade: B
 
 
[+][-]10.16.2007 at 08:20AM PDT, ID: 20086322

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_1_20070628