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

datagrid editcommand

Is it possible to use a drop combo instead of a text box
when using the EditCommand in the Datagrid? Many table
columns are bound to 'lookup' tables, user's don't care
about the foreign keys, they want the text value. Any
advice, samples or places to read are appreciated.

Thanks.
Nov 17 '05 #1
4 5950
Read up on datagrid template fields.

"Richard Roche" <ni*****@msu.edu> wrote in message
news:02****************************@phx.gbl...
Is it possible to use a drop combo instead of a text box
when using the EditCommand in the Datagrid? Many table
columns are bound to 'lookup' tables, user's don't care
about the foreign keys, they want the text value. Any
advice, samples or places to read are appreciated.

Thanks.

Nov 17 '05 #2
Hi Richard,

We can change a Textbox to a DropDownList in Datagrid edit mode. Please see
the following steps:

1. Change the bound column to a template column. You can easily do this in
the properties builder of the Datagrid. Select the columns tab, and then
click the column in the "Select columns"listbox, and you will find a link
"convert this column to a template column" upon "OK" button. Click the link
then click OK.

2. Right click the Datagrid and move to "Edit Template", then select the
template column in the pop up menu, delete the textbox in the
EditItemTemplate cell and add a DropDownList.

3. In the code behind, initialize the DropDownList in the
DataGrid1_ItemDataBound event:

Here is a snippet:

private void DataGrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.EditItem)
{
Control ctrl=e.Item.FindControl("DropDownList1");
if(ctrl!=null)
{
DropDownList dropdown=(DropDownList)ctrl;
dropdown.DataSource =DataGrid1.DataSource ;
dropdown.DataTextField = "id";
dropdown.DataValueField = "value";
dropdown.DataBind ();
}
}
}

You can check these links for more information:

Top Questions about the DataGrid Web Server Control
<http://msdn.microsoft.com/library/de...-us/dv_vstecha
rt/html/vbtchtopquestionsaboutaspnetdatagridservercontrol. asp>

Datagrid ... Combo instead of Textbox
<http://www.dotnet247.com/247reference/msgs/5/28740.aspx>

DataGrid.EditCommand Event
<http://msdn.microsoft.com/library/en...mWebUIWebContr
olsDataGridClassEditCommandTopic.asp>

Please let me know if you need more information, thanks.

Best Regards,
Lewis

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| From: "Eric Wise" <NO*****@pica.army.milSPAM>
| References: <02****************************@phx.gbl>
| Subject: Re: datagrid editcommand
| Date: Thu, 31 Jul 2003 15:41:30 -0400
| Lines: 13
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
| Message-ID: <uS*************@tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: wva-guard-cn1.wva.army.mil 155.218.88.2
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:163902
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Read up on datagrid template fields.
|
| "Richard Roche" <ni*****@msu.edu> wrote in message
| news:02****************************@phx.gbl...
| > Is it possible to use a drop combo instead of a text box
| > when using the EditCommand in the Datagrid? Many table
| > columns are bound to 'lookup' tables, user's don't care
| > about the foreign keys, they want the text value. Any
| > advice, samples or places to read are appreciated.
| >
| > Thanks.
|
|
|

Nov 17 '05 #3
Thanks, I have it working :>
Nov 17 '05 #4
I am glad to hear it. Thanks very much for participating the community.

Regards,
Lewis

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Richard Roche" <ni*****@msu.edu>
| Sender: "Richard Roche" <ni*****@msu.edu>
| References: <02****************************@phx.gbl>
<uS*************@tk2msftngp13.phx.gbl>
<jj**************@cpmsftngxa06.phx.gbl>
| Subject: Re: datagrid editcommand
| Date: Fri, 1 Aug 2003 15:37:15 -0700
| Lines: 1
| Message-ID: <04****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcNYfXT0stH/1Y/KSiKm5zsyX5piWw==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:164278
| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Thanks, I have it working :>
|

Nov 17 '05 #5

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

Similar topics

0
by: Chad Folden | last post by:
I can't figure out how to use the EditCommand for the nested datagrid .. HELP PLEASE ;-) It works perfectly for the parent datagrid, but will not display, even though the EditCommand event is...
0
by: Dan C Douglas | last post by:
I have created a hierarchical datagrid that consists of 1 datagrid nested insde of another datagrid. More technically it is actually 1 User control that contains a datagrid. I add this user control...
0
by: Mike | last post by:
I've got an app with a DataTable that gets passed around and modified by datagrids on 3 different asp.net pages. Not all columns need to be displayed, but I need them all in the datagrid so I can...
7
by: localhost | last post by:
A DataGrid with shows a label in one of the columns when in view mode. When in edit mode, I want to show a dropdown, and have the default selection set to what the textbox used to be. Right now...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
4
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a...
1
by: MrMike | last post by:
I have a sub named Bind("") which binds my a datagrid on my webform. In order to enter edit mode and edit records on this datagrid, I must make a call to Bind("") either before or after I place...
10
by: Terry Olsen | last post by:
I've got a datagrid set up to display data. I've also got an Edit,Update,Cancel column set up to allow editing of data. I've got a DropDownList (ID="ddl3")in the EditItemTemplate for a certain...
5
by: Tina | last post by:
the Edit, Update, Cancel, and Delete buttons in my datagrid are causing validation elsewhere on the page. I want to specify that these buttons should not cause validation but they have no design...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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...

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.