datagrid editcommand

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Roche

    #1

    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.
  • Eric Wise

    #2
    Re: datagrid editcommand

    Read up on datagrid template fields.

    "Richard Roche" <nikedog@msu.ed u> wrote in message
    news:024501c357 8c$ee23afe0$a30 1280a@phx.gbl.. .[color=blue]
    > 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.[/color]


    Comment

    • Lewis Wang [MSFT]

      #3
      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
      EditItemTemplat e cell and add a DropDownList.

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

      Here is a snippet:

      private void DataGrid1_ItemD ataBound(object sender,
      System.Web.UI.W ebControls.Data GridItemEventAr gs e)
      {
      if(e.Item.ItemT ype == ListItemType.Ed itItem)
      {
      Control ctrl=e.Item.Fin dControl("DropD ownList1");
      if(ctrl!=null)
      {
      DropDownList dropdown=(DropD ownList)ctrl;
      dropdown.DataSo urce =DataGrid1.Data Source ;
      dropdown.DataTe xtField = "id";
      dropdown.DataVa lueField = "value";
      dropdown.DataBi nd ();
      }
      }
      }

      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/vbtchtopquestio nsaboutaspnetda tagridservercon trol.asp>

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

      DataGrid.EditCo mmand Event
      <http://msdn.microsoft.com/library/en...mWebUIWebContr
      olsDataGridClas sEditCommandTop ic.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" <NOewise@pica.a rmy.milSPAM>
      | References: <024501c3578c$e e23afe0$a301280 a@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.65 6@tk2msftngp13. phx.gbl>
      | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
      | NNTP-Posting-Host: wva-guard-cn1.wva.army.mi l 155.218.88.2
      | Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!tk2 msftngp13.phx.g bl
      | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1639 02
      | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
      |
      | Read up on datagrid template fields.
      |
      | "Richard Roche" <nikedog@msu.ed u> wrote in message
      | news:024501c357 8c$ee23afe0$a30 1280a@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.
      |
      |
      |

      Comment

      • Richard Roche

        #4
        Re: datagrid editcommand

        Thanks, I have it working :>

        Comment

        • Lewis Wang [MSFT]

          #5
          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.ed u>
          | Sender: "Richard Roche" <nikedog@msu.ed u>
          | References: <024501c3578c$e e23afe0$a301280 a@phx.gbl>
          <uS#mfu5VDHA.65 6@tk2msftngp13. phx.gbl>
          <jj0jaw9VDHA.20 80@cpmsftngxa06 .phx.gbl>
          | Subject: Re: datagrid editcommand
          | Date: Fri, 1 Aug 2003 15:37:15 -0700
          | Lines: 1
          | Message-ID: <04a401c3587d$7 4f47540$a301280 a@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.publi c.dotnet.framew ork.aspnet
          | Path: cpmsftngxa06.ph x.gbl
          | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1642 78
          | NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
          | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
          |
          | Thanks, I have it working :>
          |

          Comment

          Working...