473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Index was out of range. Must be non-negative and less than the size of the collection

Expand|Select|Wrap|Line Numbers
  1. <asp:Panel ID="pnlScrolls" runat="server" ScrollBars="vertical" Height="600px"> 
  2.                                         <asp:GridView ID="gvRegistList" ShowFooter="True" runat="server" 
  3.                                                 AutoGenerateColumns="False" 
  4.                                             DataKeyNames="CPR_NO" BorderColor="#999999" RowStyle-BorderStyle="Solid" 
  5.                                                 Width="800px" AllowSorting="True" 
  6.                                             RowStyle-BorderWidth="1px" Font-Names="Arial" Font-Size="Medium" 
  7.                                                 CellPadding="3" BackColor="White" BorderStyle="Solid" 
  8.                                             BorderWidth="1px" GridLines="Vertical" PageSize="20" AllowPaging="True" 
  9.                                                 onpageindexchanging="gvRegistList_PageIndexChanging" 
  10.                                             ForeColor="Black" en >
  11.                                             <AlternatingRowStyle BackColor="#CCCCCC" />
  12.                                             <Columns>
  13. <%--                                               <asp:ButtonField CommandName="Select" Text="Button" HeaderText="CPR No."
  14.                                                     DataTextField="CPR_NO" SortExpression="nUserID">
  15.                                                     <ItemStyle CssClass="TDStyleLT" HorizontalAlign="Left" />
  16.                                                     <HeaderStyle CssClass="THStyle " HorizontalAlign="Left" />
  17.                                                 </asp:ButtonField>
  18.  
  19.                                                 <asp:boundfield datafield="name" headertext="Patient Name" readonly="true" />--%>
  20.                                                 <asp:TemplateField HeaderText="CPR No." >
  21.                                                     <ItemTemplate>
  22.                                                         <asp:Label ID="lblCpr" runat="server" Text='<%# Bind("CPR_NO") %>'></asp:Label>
  23.                                                     </ItemTemplate>
  24.                                                     <ItemStyle CssClass="TDStyleLT" HorizontalAlign="Left" />
  25.                                                     <HeaderStyle CssClass="THStyle" HorizontalAlign="Left" />
  26.                                                 </asp:TemplateField>
  27.  
  28.                                                 <asp:TemplateField HeaderText="NAME" >
  29.                                                     <ItemTemplate>
  30.                                                         <asp:Label ID="lblpatname" runat="server" Text='<%# Bind("NAME") %>'></asp:Label>
  31.                                                         <%--<asp:Label ID="lblCpr" runat="server" Visible="false" Text='<%# Bind("CPR_NO") %>'></asp:Label>--%>
  32.                                                     </ItemTemplate>
  33.                                                     <ItemStyle CssClass="TDStyleLT" HorizontalAlign="Left" />
  34.                                                     <HeaderStyle CssClass="THStyle" HorizontalAlign="Left" />
  35.                                                 </asp:TemplateField>
  36.                                                 <asp:TemplateField HeaderText="DATE" >
  37.                                                     <ItemTemplate>
  38.                                                         <asp:Label ID="lblDate" runat="server" Text='<%# Bind("DATE") %>'></asp:Label>
  39.                                                     </ItemTemplate>
  40.                                                     <ItemStyle CssClass="TDStyleLT" HorizontalAlign="Left" />
  41.                                                     <HeaderStyle CssClass="THStyle" HorizontalAlign="Left" />
  42.                                                 </asp:TemplateField>
  43.                                                 <asp:TemplateField HeaderText="TIME" >
  44.                                                     <ItemTemplate>
  45.                                                         <asp:Label ID="lblTimeIn" runat="server" Text='<%# Bind("TIMEIN") %>'></asp:Label>
  46.                                                         <%--<asp:Label ID="lblTimeIn" runat="server" Text='<%if # Bind("TIME") %>'></asp:Label>--%>
  47.                                                         <%--<asp:Label ID="lbGender" runat="server" Text='<% if(#Eval("NTNAEVENT")='0' { 'Male' else 'Female' }%>'></asp:Label>--%>
  48.                                                     </ItemTemplate>
  49.                                                     <ItemStyle CssClass="TDStyleLT" HorizontalAlign="Left" />
  50.                                                     <HeaderStyle CssClass="THStyle" HorizontalAlign="Left" />
  51.                                                 </asp:TemplateField>
  52.                                                 <asp:TemplateField HeaderText="NTNAEVENT" >
  53.                                                     <ItemTemplate>
  54.                                                         <asp:Label ID="lblTimeOut" runat="server" Text='<%# Bind("TIMEOUT") %>'></asp:Label>
  55.                                                     </ItemTemplate>
  56.                                                     <ItemStyle CssClass="TDStyleLT" HorizontalAlign="Left" />
  57.                                                     <HeaderStyle CssClass="THStyle" HorizontalAlign="Left" />
  58.                                                 </asp:TemplateField>
  59.  
  60.                                             </Columns>
  61.                                            <%-- <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White"/>--%>
  62.                                             <RowStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" 
  63.                                                 Height="20px" />
  64.                                             <PagerStyle HorizontalAlign="Center" BackColor="#999999" ForeColor="Black"  />
  65.                                             <FooterStyle BackColor="#CCCCCC" />
  66.                                             <HeaderStyle BorderColor="#404040" BorderStyle="Solid" BorderWidth="2px" 
  67.                                                 Wrap="True" BackColor="Black" Font-Bold="True" ForeColor="White" />
  68.                                             <PagerSettings NextPageText="Next" PreviousPageText="Previous" Visible="true" />
  69.                                             <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
  70.                                             <SortedAscendingCellStyle BackColor="#F1F1F1" />
  71.                                             <SortedAscendingHeaderStyle BackColor="#808080" />
  72.                                             <SortedDescendingCellStyle BackColor="#CAC9C9" />
  73.                                             <SortedDescendingHeaderStyle BackColor="#383838" />
  74.                                         </asp:GridView>
  75.                                         </asp:Panel>
  76.  
  77.  
  78.  
  79.  protected void gvRegistList_PageIndexChanging(object sender, GridViewPageEventArgs e)
  80.         {
  81.             //if(gvRegistList.PageIndex != null)
  82.             //    {
  83.             //    //Use
  84.             gvRegistList.PageIndex = e.NewPageIndex;
  85.             DataList();
  86.             //    }
  87.         }
  88.  
  89.  
  90. public void DataList()
  91.         {
  92.             try
  93.             {
  94.                 //Label lblCprNo = (Label)
  95.                 string strFDay, strFMonth, strFYear, strTDay, strTMonth, strTYear, strFDate, strTDate;
  96.                 strFDay = dtpFDate.SelectedDate.ToString().Substring(0, 2);
  97.                 strFMonth = dtpFDate.SelectedDate.ToString().Substring(3, 2);
  98.                 strFYear = dtpFDate.SelectedDate.ToString().Substring(6, 4);
  99.                 strFDate = strFYear + "-" + strFMonth + "-" + strFDay;
  100.  
  101.                 strTDay = dtpTDate.SelectedDate.ToString().Substring(0, 2);
  102.                 strTMonth = dtpTDate.SelectedDate.ToString().Substring(3, 2);
  103.                 strTYear = dtpTDate.SelectedDate.ToString().Substring(6, 4);
  104.                 strTDate = strTYear + "-" + strTMonth + "-" + strTDay;
  105.  
  106.                 DataTable dtSearch = new DataTable("TABLE");
  107.  
  108.                 //dtSearch = attList.Attendance_List(dtpFDate.SelectedDate.ToString().Substring(0, 10), dtpTDate.SelectedDate.ToString().Substring(0, 10), txtCpr.Text.Trim());
  109.                 dtSearch = attList.Attendance_List(strFDate, strTDate, txtCpr.Text.Trim());
  110.  
  111.                 if (dtSearch.Rows.Count > 0)
  112.                 {
  113.                     //gvRegistList.Rows. = dtSearch.Rows.Count;
  114.                     gvRegistList.DataSource = GetEmptyDataTableRegList(dtSearch.Rows.Count);
  115.                     gvRegistList.DataBind();
  116.                     lblMsg.Text = "";
  117.                     for (int iCurow = 0; iCurow <= dtSearch.Rows.Count - 1; iCurow++)
  118.                     {
  119.                         if (dtSearch.Rows[iCurow]["DATE"].ToString().Trim() != InDate.ToString().Trim())
  120.                         {
  121.                             //string DataId = gvRegistList.Rows[this.gvRegistList.SelectedRows[0].Index].Cells["CPR_NO"].Value.ToString();
  122.  
  123.                             //((Label)gvRegistList.Rows[iCurow].FindControl("lblCpr")).Text = (Convert.IsDBNull(dtSearch.Rows[iCurow]["CPR_NO"]) ? "" : dtSearch.Rows[iCurow]["CPR_NO"].ToString());
  124.                             //((Label)gvRegistList.Rows[iCurow].FindControl("lblpatname")).Text = (Convert.IsDBNull(dtSearch.Rows[iCurow]["NAME"]) ? "" : dtSearch.Rows[iCurow]["NAME"].ToString());
  125.                             //((Label)gvRegistList.Rows[iCurow].FindControl("lblDate")).Text = (Convert.IsDBNull(dtSearch.Rows[iCurow]["DATE"]) ? "" : dtSearch.Rows[iCurow]["DATE"].ToString());
  126.                             PrevTmIn = "";
  127.                             PrevTmOut = "";
  128.                             for (int jCurow = iCurow; jCurow < dtSearch.Rows.Count - 1 && dtSearch.Rows[iCurow]["DATE"].ToString().Trim() == dtSearch.Rows[jCurow]["DATE"].ToString().Trim(); jCurow++)
  129.                             {
  130.                                 //if (iCurow > intRow)
  131.                                 //{
  132.                                 //    iCurow = intRow + 1;
  133.                                 //}
  134.                                 if (dtSearch.Rows[jCurow]["NTNAEVENT"].ToString().Trim() == "0")// && dtSearch.Rows[iCurow]["DATE"].ToString().Trim() != PrevDate.ToString().Trim())  //"0" -- Time In
  135.                                 {
  136.  
  137.                                     if (PrevTmIn.ToString().Trim() == "")
  138.                                     {
  139.                                         ((Label)gvRegistList.Rows[iCurow].FindControl("lblCpr")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["CPR_NO"]) ? "" : dtSearch.Rows[jCurow]["CPR_NO"].ToString());
  140.                                         ((Label)gvRegistList.Rows[iCurow].FindControl("lblpatname")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["NAME"]) ? "" : dtSearch.Rows[jCurow]["NAME"].ToString());
  141.                                         ((Label)gvRegistList.Rows[iCurow].FindControl("lblDate")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["DATE"]) ? "" : dtSearch.Rows[jCurow]["DATE"].ToString());
  142.                                         ((Label)gvRegistList.Rows[iCurow].FindControl("lblTimeIn")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["TIMEIN"]) ? "" : dtSearch.Rows[jCurow]["TIMEIN"].ToString());
  143.                                     }
  144.                                     else if (dtSearch.Rows[jCurow]["TIMEIN"].ToString().Trim() != PrevTmIn.ToString().Trim())
  145.                                     {
  146.                                         ((Label)gvRegistList.Rows[iCurow + 1].FindControl("lblCpr")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["CPR_NO"]) ? "" : dtSearch.Rows[jCurow]["CPR_NO"].ToString());
  147.                                         ((Label)gvRegistList.Rows[iCurow + 1].FindControl("lblpatname")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["NAME"]) ? "" : dtSearch.Rows[jCurow]["NAME"].ToString());
  148.                                         ((Label)gvRegistList.Rows[iCurow + 1].FindControl("lblDate")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["DATE"]) ? "" : dtSearch.Rows[jCurow]["DATE"].ToString());
  149.                                         ((Label)gvRegistList.Rows[iCurow + 1].FindControl("lblTimeIn")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["TIMEIN"]) ? "" : dtSearch.Rows[jCurow]["TIMEIN"].ToString());
  150.                                     }
  151.                                     PrevTmIn = dtSearch.Rows[jCurow]["TIMEIN"].ToString().Trim();
  152.                                     //intRow = iCurow;
  153.                                 }
  154.                                 else if (dtSearch.Rows[jCurow]["NTNAEVENT"].ToString() == "1") //"1" -- Time Out
  155.                                 {
  156.                                     if (PrevTmOut.ToString().Trim() == "")
  157.                                     {
  158.                                         ((Label)gvRegistList.Rows[iCurow].FindControl("lblCpr")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["CPR_NO"]) ? "" : dtSearch.Rows[jCurow]["CPR_NO"].ToString());
  159.                                         ((Label)gvRegistList.Rows[iCurow].FindControl("lblpatname")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["NAME"]) ? "" : dtSearch.Rows[jCurow]["NAME"].ToString());
  160.                                         ((Label)gvRegistList.Rows[iCurow].FindControl("lblDate")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["DATE"]) ? "" : dtSearch.Rows[jCurow]["DATE"].ToString());
  161.                                         ((Label)gvRegistList.Rows[iCurow].FindControl("lblTimeOut")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["TIMEOUT"]) ? "" : dtSearch.Rows[jCurow]["TIMEOUT"].ToString());
  162.                                     }
  163.                                     else if (dtSearch.Rows[jCurow]["TIMEOUT"].ToString().Trim() != PrevTmOut.ToString().Trim())
  164.                                     {
  165.                                         ((Label)gvRegistList.Rows[iCurow + 1].FindControl("lblCpr")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["CPR_NO"]) ? "" : dtSearch.Rows[jCurow]["CPR_NO"].ToString());
  166.                                         ((Label)gvRegistList.Rows[iCurow + 1].FindControl("lblpatname")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["NAME"]) ? "" : dtSearch.Rows[jCurow]["NAME"].ToString());
  167.                                         ((Label)gvRegistList.Rows[iCurow + 1].FindControl("lblDate")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["DATE"]) ? "" : dtSearch.Rows[jCurow]["DATE"].ToString());
  168.                                         ((Label)gvRegistList.Rows[iCurow + 1].FindControl("lblTimeOut")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["TIMEOUT"]) ? "" : dtSearch.Rows[jCurow]["TIMEOUT"].ToString());
  169.                                     }
  170.                                     PrevTmOut = dtSearch.Rows[jCurow]["TIMEOUT"].ToString().Trim();
  171.                                 }
  172.                                 PrevDate = dtSearch.Rows[jCurow]["DATE"].ToString();
  173.  
  174.                             }
  175.                             intRow = iCurow;
  176.                         }
  177.                         InDate = dtSearch.Rows[iCurow]["DATE"].ToString();
  178.  
  179.                         //((Label)gvRegistList.Rows[iCurow].FindControl("lblCpr")).Text = (Convert.IsDBNull(dtSearch.Rows[iCurow]["CPR_NO"]) ? "" : dtSearch.Rows[iCurow]["CPR_NO"].ToString());
  180.  
  181.                     }
  182.  
  183.                     //gvRegistList.DataSource = dtSearch;
  184.                     //gvRegistList.DataBind();
  185.  
  186.                 }
  187.                 else
  188.                 {
  189.                     lblMsg.Text = "No Records Available.";
  190.                     gvRegistList.DataSource = GetEmptyDataTableRegList(20);
  191.                     gvRegistList.DataBind();
  192.                 }
  193.             }
  194.             catch (Exception ex)
  195.             {
  196.                 lblMsg.Text = "Exception caught here: " + ex.ToString();
  197.             }
  198.         }
Jun 25 '13 #1
1 1361
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

It would help to know which line threw the error.
Jun 25 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Brett L. Moore | last post by:
Hi, I have had trouble determining whether the STL list.size() operation is O(1) or O(n). I know the list is a doubly-linked list, so if the size() operation begins at the head, then counts to...
6
by: Joe | last post by:
I have a: vector<string> which contains a few dozen elements. I want to find the index of the element containing a certain string. for example: vector<string> strings;...
16
by: ES Kim | last post by:
"A Book on C" explains a technique to use an arbitrary array index range. int* p = malloc(sizeof(int) * 10) - 1; This way, the allocated array can be accessed with index range 1 ~ 10, not 0 ~...
12
by: pamelafluente | last post by:
Hi guys, Is it possible to get the current index, when iterating with FOR EACH on some collection (implementing ILIST) without using and external counting variable (, that is somehow getting...
2
by: Harry | last post by:
Good Day To all, When i am declaring a array for e.g char ....it means i am declaring array of 45 characters each of which has a maximum,minimum value limit or range...for example in...
1
by: =?Utf-8?B?UnlhbiBBbmRydXM=?= | last post by:
Does the int index of the DataTable.Rows collection place a size limit on how large a datatable can be? If not then how do you index DataTable.Rows for sizes greater than what an int can handle?
1
by: =?Utf-8?B?SkI=?= | last post by:
Hello As I debug the C# code with a break point and by pressing F11 I eventually get a message stating: ContextSwitchDeadlock was detected Message: The CLR has been unable to transition from...
1
by: vivek samantray | last post by:
I have a query.When i try to create a index on one of the table the index gets created but when i take the output it stuill shows "TABLE ACCESS FULL" Please see below what i did QUERY ======...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.