473,395 Members | 1,969 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,395 software developers and data experts.

Different Server Controls in DataGrid

Can anyone provide any advice or article on creating DataGrid and bind it with data but for every column of data, there may be different Server Controls. To make it clear, let say i want bind 1 field in one DataGrid, but for the only field i want to bind, i may have Label control from rows 1 - 5 and , i want to bind checkboxes to rows from row 6 - 8 and i want to bind again the label controls from row 9 - 11. Can i do that in DAtagrid in ASP.NET ???? Thanks you very much
Nov 18 '05 #1
1 1109
It's possible but could be very costly

You have to Handle the ItemDataBound method of the datagrid. One of the parameters of the method is the Item row of the datagrid. You can use it to get a handle on the cell or column which you want for that row and dynamically add your control

For example

private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e

switch(condition) //your conditio

case "DropDown": //your matc
DropDownList ddl = new DropDownList()
e.Item.Cells[yourcellindex].Controls.Add(ddl)
break
case "TextBox": //your matc
TextBox txt = new TextBox()
e.Item.Cells[yourcellindex].Controls.Add(txt)
break
default
Label lbl = new Label()
e.Item.Cells[yourcellindex].Controls.Add(lbl)
break

HTH
Suresh

----- Machi wrote: ----

Can anyone provide any advice or article on creating DataGrid and bind it with data but for every column of data, there may be different Server Controls. To make it clear, let say i want bind 1 field in one DataGrid, but for the only field i want to bind, i may have Label control from rows 1 - 5 and , i want to bind checkboxes to rows from row 6 - 8 and i want to bind again the label controls from row 9 - 11. Can i do that in DAtagrid in ASP.NET ???? Thanks you very much
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bob Rosen | last post by:
I would like to place some button controls on a web page underneath a DataGrid control. Since the height of the DataGrid depends on the number of rows displayed, which is determined by user...
8
by: Inigo Jimenez | last post by:
I have an ASP .net web application installed in a Windows 2003 server. This web application has a webform that has a Datagrid. This Datagrid is filled with the data of a SQL table. I have a...
1
by: Ryan McLean | last post by:
Hi everyone! What is happening is the method: sub_btnSubmitClicked is being executed every time any other object with a Handler is executed. I am trying not to use the withevents and handles...
4
by: Steve Bywaters | last post by:
(In my transition from ASP to ASP.NET) *When* would I use at "runat server" tag on a button, as opposed to a normal button? If I set up a search area on a page, with a 'Search' button that...
12
by: Daniel Walzenbach | last post by:
Hi, I want to display a Label in a DataGrid according to some condition. I therefore check whether the condition is true in the ItemDateBound EventHandler of the DataGrid. Unfortunately the...
2
by: David C | last post by:
I designed a datagrid with editable server controls such as text boxes, dropdowns in each row. That way, the user does not have to click "Edit" to get the editable controls. And with one save...
5
by: siaj | last post by:
Hello All, Can any one give me a clue when to use Web Server controls/ HTML server controls/HTML Controls. As I understand .. HTML controls should be used if u dont need to refer it in the code...
5
by: Jeronimo Bertran | last post by:
I have a DataGrid that gets filled based on a filter which is defined by the values that the user selects on several controls. When the page postbacks after changing the selection on the filter...
2
by: toddw607 | last post by:
Hi Everyone! I have a ASP.NET webform that brings data in from SQL Server 2000 and displays it on a page. I want to update the webpage while in IE using the following code: <%@ Import...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.