add the dropdownlist to the datagrid

3 views
Skip to first unread message

shyam sundar

unread,
Oct 24, 2005, 3:51:06 AM10/24/05
to Techdot...@googlegroups.com
add the dropdownlist to the datagrid and it connect database an
dget values to my project urgently

ST Sreetharan

unread,
Oct 24, 2005, 4:29:57 AM10/24/05
to Techdot...@googlegroups.com
Hi
You can do this easily
Add a template column to the grid, drag a dropdownlist to that template column.
in the ItemDataBound event write the following
 

protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
{

try
{
if(e.Item.ItemType!=ListItemType.Header && e.Item.ItemType!=ListItemType.Footer)
{
DropdownList ddlGrid=(DropDownList) e.Item.Cells[cell Number where your control is];

//here write your binding code to bind dropdown list, you can get the data in the same row using //e.Item.Cells[0] or by mentioning the cell number wherever you want.

}

}

the item databound event is called after binding each row. if you are passing some argument while binding the data you can do it by writing your code within this method

 

Regards

Sreetharan S.T

shyam sundar

unread,
Oct 24, 2005, 4:36:30 AM10/24/05
to Techdot...@googlegroups.com
Hi,

what u have given the code, is correct, but i want to show the data
from datatable. if i have 4 or 5 records in a table. i want to show
the qty of respective rec in dropdownlist.

Ravi

unread,
Oct 24, 2005, 4:47:30 AM10/24/05
to Techdot...@googlegroups.com
Hi all,
 
Whats the purpose of using the Page Directive "SmartNavigation"?
 
Regards,
Ravi.P

BabuLives

unread,
Oct 24, 2005, 4:54:29 AM10/24/05
to .NetIndia
hai ravi..

The purpose of Smart Navigation property to maintain the scroll
position of pages across postbacks.Supposing we have a very long page
with lots of controls. A user is in the middle of the page and triggers
an event (say click event), which causes the page to postback. Then the
page will be reloaded and the position would go to the top.

This could be particularly annoying if the user has to scroll down long
and repetitively.

To avoid this, ASP.NET provides the SmartNavigation property for the
page which takes care of the scroll position.

SmartNavigation also avoids the flickering of the page when the page is
reloaded.

It can be enabled by simply setting its value to true in the page
directive, as follows:-

<%Page smartNavigation="True" %>

Alternatively, it can be specified as a global setting in the
web.config as follows:-

<configuration>
<system.web>
<pages smartNavigation="true"/>
</system.web>
</configuration>

Regards,
Satheesh

Shivprasad Koirala

unread,
Oct 24, 2005, 4:58:42 AM10/24/05
to .NetIndia
how about using templates
-------
Regards ,
C#, VB.NET , SQL SERVER , UML , DESIGN Patterns Interview question book
http://www.geocities.com/dotnetinterviews/
My Interview Blog
http://spaces.msn.com/members/dotnetinterviews/

shyam sundar

unread,
Oct 25, 2005, 1:17:11 AM10/25/05
to Techdot...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages