ASP.NET

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentASP.NET

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old November 15th, 2012, 10:52 AM
naveendkt naveendkt is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 2 naveendkt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 15 m 22 sec
Reputation Power: 0
Error on Updating GridView row

I am getting error "Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index " on updating the gridview. I have checked the rowindex in update function and its good. But i checked the gridview row count as grdMain.Rows.Count it is showing 0. My update event is below

BO.FranchiseInquiry f = new BO.FranchiseInquiry();
int index = grdMain.EditIndex;

lbl.Text = grdMain.Rows.Count.ToString();

GridViewRow row = (GridViewRow)grdMain.Rows[index];
TextBox txtNote = (TextBox)row.FindControl("txtNote");

f.FranchiseInquiryID = Int32.Parse(grdMain.DataKeys[index].Value.ToString());
f.Note = txtNote.Text.Trim();


fd.UpdateFranchiseInquiry(f);
grdMain.EditIndex = -1;

BindData();


<asp:GridView ID="grdMain" runat="server" EmptyDataText="No Records Found" AutoGenerateColumns="False" DataKeyNames="FranchiseInquiryID"
OnRowEditing="grdMain_RowEditing" OnRowUpdating="grdMain_RowUpdating" OnRowCancelingEdit="grdMain_RowCancelingEdit">
<Columns>
<asp:BoundField DataField="FranchiseInquiryID" Visible="false" HeaderText="FranchiseInquiryID" />
<asp:BoundField HeaderText="First Name" DataField="FirstName" ReadOnly="true" />
<asp:BoundField HeaderText="Last Name" DataField="LastName" ReadOnly="true" />
<asp:BoundField HeaderText="Phone" DataField="Phone" ReadOnly="true" />
<asp:BoundField HeaderText="Email" DataField="Email" ReadOnly="true" />
<asp:BoundField HeaderText="Zip Code" DataField="Zip" ReadOnly="true" />
<asp:BoundField HeaderText="Liquid Capital Available" DataField="LiquidCapital" ReadOnly="true" />
<asp:TemplateField HeaderText="Notes">
<ItemTemplate>
<%# Eval("Note")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtNote" Text='<%# Eval("Note")%>' />
</EditItemTemplate>
</asp:TemplateField>

<asp:CommandField ShowEditButton="true" ShowDeleteButton="false" ButtonType="Button" CausesValidation="false"/>

</Columns>
</asp:GridView>


I am not getting why the grid count becomes 0 in line lbl.Text = grdMain.Rows.Count.ToString();

Please help me.

Reply With Quote
  #2  
Old May 15th, 2013, 08:32 AM
annaharris annaharris is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Apr 2013
Posts: 27 annaharris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 21 m 28 sec
Reputation Power: 0
Have you checked the total no. of entries that you are fetching from rowindex in update function?

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentASP.NET > Error on Updating GridView row


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap