datagrid editcommand

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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.
    Richard Roche Guest

  2. Similar Questions and Discussions

    1. datagrid, paging and editcommand colum
      I have a datagrid in my page which has one editcommandcolumn with edit, update and cancel options. Paging is also enabled in my datagrid. When...
    2. EditCommand event
      Does anyone know how DataGrid knows which index of an Edit button/link caused the postback so as to pass it along as an argument to EditCommand...
    3. EditCommand event in Datagrid question
      Hi, I have a few questions about the EditCommand event in the DataGrig in asp.net. When I get to the EditCommand event in my code I need to...
    4. Non-displayed values in DataGrid that stay accessible in EditCommand event?
      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...
    5. EditCommand on Nested DataGrid
      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...
  3. #2

    Default Re: datagrid editcommand

    Read up on datagrid template fields.

    "Richard Roche" <nikedog@msu.edu> wrote in message
    news:024501c3578c$ee23afe0$a301280a@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.

    Eric Wise Guest

  4. #3

    Default Re: datagrid editcommand

    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
    <[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstecha[/url]
    rt/html/vbtchtopquestionsaboutaspnetdatagridservercontrol. asp>

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

    DataGrid.EditCommand Event
    <[url]http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWebUIWebContr[/url]
    olsDataGridClassEditCommandTopic.asp>

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

    Best Regards,
    Lewis

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

    --------------------
    | From: "Eric Wise" <NOewise@pica.army.milSPAM>
    | References: <024501c3578c$ee23afe0$a301280a@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#mfu5VDHA.656@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" <nikedog@msu.edu> wrote in message
    | news:024501c3578c$ee23afe0$a301280a@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.
    |
    |
    |

    Lewis Wang [MSFT] Guest

  5. #4

    Default Re: datagrid editcommand

    Thanks, I have it working :>
    Richard Roche Guest

  6. #5

    Default Re: datagrid editcommand

    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" <nikedog@msu.edu>
    | Sender: "Richard Roche" <nikedog@msu.edu>
    | References: <024501c3578c$ee23afe0$a301280a@phx.gbl>
    <uS#mfu5VDHA.656@tk2msftngp13.phx.gbl>
    <jj0jaw9VDHA.2080@cpmsftngxa06.phx.gbl>
    | Subject: Re: datagrid editcommand
    | Date: Fri, 1 Aug 2003 15:37:15 -0700
    | Lines: 1
    | Message-ID: <04a401c3587d$74f47540$a301280a@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 :>
    |

    Lewis Wang [MSFT] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139