IT Community - Software Programming, Web Development and Technical Support

ASP.NET Data Controls

This is a discussion on ASP.NET Data Controls within the ASP and ASP.NET Programming forums, part of the Web Development category; I am a newbie to Asp.net development i plan to use Data Bound controls for displaying informations. I have ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 08-02-2007, 09:44 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up ASP.NET Data Controls

I am a newbie to Asp.net development i plan to use Data Bound controls for displaying informations. I have tried data-bound controls such as the DataGrid, DataList, GridView, FormView, DetailsView, and Repeater Controls for simpler usage but this requirment is an extensive one.so i want to get a clear picture of the controls which i am going to use.

can anybody suggest a best solution....

thanks in advance...,

Last edited by Venkat : 08-04-2007 at 01:23 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-03-2007, 01:49 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 632
oxygen is on a distinguished road
Question Re: Implementation Data Controls in asp.net

hi venkat,

can i know what is the purpose of using data bound controls in a Web application.
__________________
The OXYGEN
Delivers edgy, intelligent Technology to all...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-03-2007, 01:52 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: Implementation Data Controls in asp.net

Data-bound Web server controls are controls that can be bound to a data source control to make it easy to display and modify data in your Web application. Data-bound Web server controls are composite controls that combine other ASP.NET Web controls, such as Label and TextBox controls, into a single layout.

For example, a data-bound control such as a DetailsView control can bind to a set of results such as a table of employees containing each employee's name, address, job title, and so on. Within the DetailsView control, you can bind Label controls to a single data values such as the name or address field to create the data layout in the page.

In addition to enabling you to bind the control to a set of data results, data-bound controls enable you to customize the layout of the control using templates. They also provide a convenient model for handling and canceling events.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 08-03-2007, 01:54 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 632
oxygen is on a distinguished road
Question Re: Implementation Data Controls in asp.net

how data Web server controls bind to data as well as the data-bound controls that are included with ASP.NET?
__________________
The OXYGEN
Delivers edgy, intelligent Technology to all...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 08-03-2007, 01:56 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: Implementation Data Controls in asp.net

Binding a Data-bound Web Server Control to Data

You can work with a data-bound control by binding it to a data source control such as an ObjectDataSource or SqlDataSource control. The data source control connects to a data source such as a database or middle-tier object and then retrieves or updates data. The data-bound control can then use this data. To perform the binding, you set the data-bound control's DataSourceID property to point to a data source control. When a data-bound control is bound to a data source control, little or no additional code is required for data operations, because the data-bound control can automatically take advantage of the data services provided by the data source control.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 08-03-2007, 01:57 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 632
oxygen is on a distinguished road
Question Re: Implementation Data Controls in asp.net

Can anybody tell me more information about other data source controls?
__________________
The OXYGEN
Delivers edgy, intelligent Technology to all...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 08-03-2007, 02:17 AM
JSureshkumar JSureshkumar is offline
D-Web Sr.Programmer
 
Join Date: Feb 2007
Location: in someone's heart
Posts: 139
JSureshkumar is on a distinguished road
Send a message via Skype™ to JSureshkumar
Default Re: Implementation Data Controls in asp.net

DetailsView Control

The DetailsView control renders a single record at a time as a table and provides the capability to page through multiple records, as well as to insert, update, and delete records. The DetailsView control is often used in master-detail scenarios where the selected record in a master control such as a GridView control determines the record displayed by the DetailsView control.
__________________
J Suresh Kumar
Google Hacks
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 08-03-2007, 02:18 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: Implementation Data Controls in asp.net

FormView Control

The FormView control renders a single record at a time from a data source and provides the capability to page through multiple records, as well as to insert, update, and delete records, similar to the DetailsView control. However, the difference between the FormView and the DetailsView controls is that the DetailsView control uses a table-based layout where each field of the data record is displayed as a row in the control. In contrast, the FormView control does not specify a pre-defined layout for displaying a record. Instead, you create templates that contain controls to display individual fields from the record. The template contains the formatting, controls, and binding expressions used to lay out the form.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 08-03-2007, 02:20 AM
JSureshkumar JSureshkumar is offline
D-Web Sr.Programmer
 
Join Date: Feb 2007
Location: in someone's heart
Posts: 139
JSureshkumar is on a distinguished road
Send a message via Skype™ to JSureshkumar
Thumbs up Re: Implementation Data Controls in asp.net

Repeater Control

The Repeater control renders a read-only list from a set of records returned from a data source. Like the FormView control, the Repeater control does not specify a built-in layout. Instead you create the layout for the Repeater control using templates.
__________________
J Suresh Kumar
Google Hacks
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 08-03-2007, 02:21 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: Implementation Data Controls in asp.net

we have DataList Control also..

The DataList control renders data as table and enables you to display data records in different layouts, such as ordering them in columns or rows. You can configure the DataList control to enable users to edit or delete a record in the table. (The DataList control does not take advantage of the capabilities of data source controls for modifying data; you must supply this code yourself.) The DataList control differs from the Repeater control in that the DataList control explicitly places items in an HTML table, where as the Repeater control does not.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #11 (permalink)  
Old 08-03-2007, 02:23 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: Implementation Data Controls in asp.net

hi guys one more data bound control in asp.net....


GridView Control

The GridView control displays data as a table and provides the capability to sort columns, page through data, and edit or delete a single record.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 08-03-2007, 05:03 AM
garunprasad garunprasad is offline
D-Web Trainee
 
Join Date: Mar 2007
Location: Chennai
Posts: 45
garunprasad is on a distinguished road
Send a message via ICQ to garunprasad Send a message via AIM to garunprasad Send a message via MSN to garunprasad Send a message via Yahoo to garunprasad Send a message via Skype™ to garunprasad
Question Re: Implementation Data Controls in asp.net

Hi all
How can I add a checkbox to each row of a GridView dynamically? I realise that this can be done by using <ItemTemplate></ItemTemplate> in the aspx page, but I'm trying to have columns in the GridView corresponding to different datasets.
//--
foreach (DataColumn dc in ds.Tables[0].Columns)
{
BoundField bField = new BoundField();
bField.HeaderText = dc.ColumnName;
bField.DataField = dc.ColumnName;
GridView1.Columns.Add(bField);
}
//--
I want a checkbox appended to each of the rows in the Gridview as well. How can I do that? Any pointers would be appreciated.

Thanks
__________________
G.A.P
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 08-03-2007, 05:07 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: Implementation Data Controls in asp.net

hi

You could add code to your gridview's DataBound event:

protected void gvData_DataBound(object sender, EventArgs e)
{
foreach (GridViewRow objRow in gvData.Rows)
{
TableCell tcCheckCell = new TableCell();
CheckBox chkCheckBox = new CheckBox();
tcCheckCell.Controls.Add(chkCheckBox);
objRow.Cells.AddAt(0, tcCheckCell);
}
}
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 08-03-2007, 05:09 AM
JSureshkumar JSureshkumar is offline
D-Web Sr.Programmer
 
Join Date: Feb 2007
Location: in someone's heart
Posts: 139
JSureshkumar is on a distinguished road
Send a message via Skype™ to JSureshkumar
Smile Re: Implementation Data Controls in asp.net

Hi,
if you need this checkbox to appear for each DataSet, you can still use ItemTemplate in your GridView declaration. Then you can add your dynamically created columns.
However, if you only need this checkbox is some cases, you needto add TemplateField column to your grid and assign ItemTemplate property. You need to have instance of a class implementing ITemplate interface to assign it to ITemTemplate property.
To get this instanace you can:
1. Create a UserContorl with CheckBox inside and load it using LoadTemplate method of your page
2. Use sample class and code from: It Could Be Done!: Implementing ITemplate as Anonymous Method
1. This sample uses Button instead of CheckBox, just need to replace
2. This sample demonstrates implementation of ITemplate for GridView column
Note, that if you have ViewState enabled for your GridView, you will probably lose your checkbox on postback. So, this simple TemlateField sample works only for GridViews with disabled ViewState. If data binding on each postback is not acceptable for you, please ask more questions here.
__________________
J Suresh Kumar
Google Hacks
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 08-03-2007, 05:11 AM
H2o H2o is offline
D-Web Analyst
 
Join Date: Jul 2007
Posts: 245
H2o is on a distinguished road
Default Re: Implementation Data Controls in asp.net

Hi garunprasad,

Why cant you try another approach.
give an itemTemplate with checkbox in each row.
make it visible or invisible according to your need.(according to DataSet)

Regards,
__________________
H2O

Without us, no one can survive..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #16 (permalink)  
Old 08-03-2007, 05:13 AM
garunprasad garunprasad is offline
D-Web Trainee
 
Join Date: Mar 2007
Location: Chennai
Posts: 45
garunprasad is on a distinguished road
Send a message via ICQ to garunprasad Send a message via AIM to garunprasad Send a message via MSN to garunprasad Send a message via Yahoo to garunprasad Send a message via Skype™ to garunprasad
Default Re: Implementation Data Controls in asp.net

Hi guys
Thanks for the replies. I managed to add a check box using an approach similar to the one suggested by JSuresh, but involved creating a class extending INamingContainer, ITemplate.
Found this link really helpful: WEBSWAPP Development Inc.
However, I'm having trouble getting to this control by using GridViewRow's FindControl method. For some reason, it does not locate the control in the row with the ID that has been allocated to the checkbox.
Here is my code:
//--
foreach (GridViewRow gvr in GridView1.Rows)
{
CheckBox chkSelect = (CheckBox)gvr.FindControl("chkUpdate");
if (chkSelect != null && chkSelect.Checked)
{
gvr.Cells[5].Text = ddlChangeStatus.SelectedValue;
DataRow dr = ds.Tables[0].Rows[gvr.DataItemIndex];
dr["Status"] = ddlChangeStatus.SelectedValue;
}
}
//--
It returns a null for that particular control. Any suggestions??
Thanks
__________________
G.A.P
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #17 (permalink)  
Old 08-03-2007, 05:15 AM
JSureshkumar JSureshkumar is offline
D-Web Sr.Programmer
 
Join Date: Feb 2007
Location: in someone's heart
Posts: 139
JSureshkumar is on a distinguished road
Send a message via Skype™ to JSureshkumar
Smile Re: Implementation Data Controls in asp.net

Hi,
I am not sure how is INamingContainer used on template class, but I think it is unrelated.
1. When do you add your new columns and assign ItemTemplate property? Is it page_load, page_init or somewhere else?
2. Do you have ViewState enabled on your GridView?
__________________
J Suresh Kumar
Google Hacks
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #18 (permalink)  
Old 08-03-2007, 05:17 AM
garunprasad garunprasad is offline
D-Web Trainee
 
Join Date: Mar 2007
Location: Chennai
Posts: 45
garunprasad is on a distinguished road
Send a message via ICQ to garunprasad Send a message via AIM to garunprasad Send a message via MSN to garunprasad Send a message via Yahoo to garunprasad Send a message via Skype™ to garunprasad
Question Re: Implementation Data Controls in asp.net

Hi,

The columns are being added elsewhere, as you put it. I might be doing it wrong altogether, but when the gridview is displayed, the checkboxes have an ID similar to "#GridView_ctl01_chkUpdate" (as viewed using the web developer toolbar in Firefox).
But I'm looking only for "chkUpdate" using the FindControl method.
What exactly should I be looking for in the FindControl method?
Would it be something similar to "#GridView_ctl01_chkUpdate"? perhaps I could use something like a regular expression to search for the checkbox.
__________________
G.A.P
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #19 (permalink)  
Old 08-03-2007, 05:18 AM
JSureshkumar JSureshkumar is offline
D-Web Sr.Programmer
 
Join Date: Feb 2007
Location: in someone's heart
Posts: 139
JSureshkumar is on a distinguished road
Send a message via Skype™ to JSureshkumar
Default Re: Implementation Data Controls in asp.net

Hi,

IDs are correct. ctl01 is ID of the GridViewRow and it looks for its child controls with correct prefixes.
Depending on answers to previous questions, I may be able to explain what is the problem.
__________________
J Suresh Kumar
Google Hacks
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #20 (permalink)  
Old 08-03-2007, 05:19 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: Implementation Data Controls in asp.net

Hi,

Are you defining the name of your checkbox explicitly? It is not enough to just define the item, you need to set its ID property or it won't be found by findcontrol:

CheckBox chkMyBox = new CheckBox();
chkMyBox.ID = "chkMyBox";
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/asp-asp-net-programming/3113-asp-net-data-controls.html
Posted By For Type Date
ASP.NET Data Controls - Page 2 - DiscussWeb IT Community - Technical Support and Technology Discussions This thread Refback 08-27-2007 12:10 AM
DiscussWeb IT Community - Technical Support and Technology Discussions This thread Refback 08-17-2007 02:02 AM

Similar Threads
Thread Thread Starter Forum Replies Last Post
silverlight controls for .net stevejhon ASP and ASP.NET Programming 1 03-25-2009 10:31 AM
silverlight controls for .net stevejhon ASP and ASP.NET Programming 0 03-23-2009 01:55 AM
How can we Dynamically create web controls Kirubhananth ASP and ASP.NET Programming 3 03-14-2008 09:00 PM
WebParts controls S.Vinothkumar ASP and ASP.NET Programming 5 11-16-2007 02:06 AM
Asp.net controls not supported by Ajax? Gopisoft ASP and ASP.NET Programming 0 07-16-2007 11:22 PM


All times are GMT -7. The time now is 09:19 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
Miami FL Divorce Lawyers      Pittsburgh Personal Injury Law      Austin TX Auto Accident Lawyer
Sedo - Buy and Sell Domain Names and Websites project info: discussweb.com Statistics for project discussweb.com etracker® web controlling instead of log file analysis

SEO by vBSEO 3.0.0