.Net Framework, Asp.net, Ado.net, .Net Remoting, .Net Webservice, SQL, XML, XSLT, WCF, WPF, WWF NHibernate, Ajax, Jquery, DHTML

Ado.netAsp.Net 2.0SQLC-SharpXMLFrameworkIISXMLWebServiceArchitecture
UMLProject ManagementSDLCMethodologiesDesign PatterenOOPWCF.Net RemotingWWF
MVPMVCSilver LightN-HibernateAjaxJ-QuerySEO-MarketingSite MapPhp

GridView sample pagging, sorting, databound, deleting

Customer Details
IdNameAddress 
1Customer 0Address Road No0, Room No0
2Customer 1Address Road No1, Room No3
3Customer 2Address Road No2, Room No6
4Customer 3Address Road No3, Room No9
5Customer 4Address Road No4, Room No12
6Customer 5Address Road No5, Room No15
7Customer 6Address Road No6, Room No18
8Customer 7Address Road No7, Room No21
9Customer 8Address Road No8, Room No24
10Customer 9Address Road No9, Room No27
12345
You are viewing page 1 of 5


To find any child controls and to set/get the property we can use this event.
Gridview RowDataBound example
<asp:GridView Id="GridView1" runat="server" onrowdatabound="GridView1_RowDataBound">
1:
2:protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
3: {
4: if (e.Row.RowType == DataControlRowType.DataRow)
5: {
6: GridView grv = (GridView)e.Row.FindControl("GridView1A");
7: grv.Caption = "Order Details";
8: grv.DataSource = SampleData.Service.Instance.GetSampleCustomers()[e.Row.RowIndex].OrderList;
9: grv.DataBind();
10:
11: Button _delete= (Button )e.Row.FindControl("btnDelete");
12: _delete.Attributes.Add("onClick", "return ConfirmDelete();");
13:
14:
15: }
16: }
17:


Gridview PageIndexChanging example
<asp:GridView Id="GridView1" runat="server" OnPageIndexChanging="GridView1_PageIndexChanging">
1:
2: protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
3: {
4: // Cancel the paging operation if the user attempts to navigate
5: // to another page while the GridView control is in edit mode.
6: if (GridView1.EditIndex != -1)
7: {
8: // set cancel property ture.
9: e.Cancel = true;
10:
11: // Display an message with problem occured
12: int newPageNumber = e.NewPageIndex + 1;
13: lblMessage.Text = "Please update the record before moving to page " + newPageNumber.ToString() + ".";
14: }
15: else
16: {
17:
18: GridView1.PageIndex = e.NewPageIndex;
19: //now call the databind method again.
20: this.LoadCustomer();
21: lblMessage.Text = "";
22: }
23:
24: }
25:
Leave your comment.
Name
Email
Comments
Tell Us3144+5 =

Reduce your Dialy IT Cost, Consult with us
Stay healthy in recession

Advertisement
Sponsored by

Privacy Policy ©2009 ETG Consultancy, All Rights Reserved Terms & Conditions
Asp.net, Ado.net, .Net Remoting, .Net Webservice, SQL, XML, XSLT, WCF, WPF, WWF NHibernate, Ajax, Jquery, DHTML