C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » DataGridView »

Handling Errors in Gridview


Posted Date: 28 Jul 2009    Resource Type: Code Snippets    Category: DataGridView
Author: satyaMember Level: Diamond    
Rating: 1 out of 5Points: 10





Handling Error in Gridview



Description:


The below code can be used to handle the errors in gridview

using row updated command.




Design View:


< form id="form1" runat="server" >
< div >

< asp:Label id="lblError" EnableViewState="false"
CssClass="error" Runat="server" / >

< asp:GridView id="GridView1" DataKeyNames="Id"
AutoGenerateEditButton="true" DataSourceID="srcMovies"
OnRowUpdated="grdMovies_RowUpdated" Runat="server" / >

< asp:SqlDataSource id="srcMovies" SelectCommand="SELECT Id,Title FROM Movies"
UpdateCommand="UPDATE DontExist SET Title=@Title
WHERE Id=@ID" ConnectionString="<%$ ConnectionStrings:Movies %>"
Runat="server" / >

< /div >
< /form >

Code Behind:



protected void Gridview1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
if (e.Exception != null)
{
lblError.Text = e.Exception.Message;
e.ExceptionHandled = true;
}
}



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Handling Errors in Gridview  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Checkboxlist in GridView
Previous Resource: Exporting DataGridView into Excel
Return to Discussion Resource Index
Post New Resource
Category: DataGridView


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use