Stumped on dropdownlist, editcommand

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Stumped on dropdownlist, editcommand

    I've been googling this and know it's been covered often, but I can't
    get mine to work.

    I'm using a dropdown list when editing the record in the datagrid.
    I'm using an arraylist (although I'm willing to change) to populate the
    dropdown.

    The problem is selecting the item in the dropdown that corresponds to
    the current record's value.

    I have the code below. I'm looking for the simplest way to select the
    correct value in the dropdownlist. I notice in the OnItemDataBound I
    have to cast the item cells to textboxes when the item is being edited,
    but I'm not sure how to find the value I need.


    private void dg_Columns_Edit(object source,
    System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
    dg_Columns.EditItemIndex = e.Item.ItemIndex;
    rptDataTypes = new ArrayList();
    rptDataTypes.Add("DESC");
    rptDataTypes.Add("ASC");

    FillColumnGrid();
    DropDownList dl =
    ((DropDownList)dg_Columns.Items[e.Item.ItemIndex].Cells[5].FindControl("ddlSortDir"));
    dl.DataSource = rptDataTypes;
    dl.DataBind();


    }

    jhcorey@yahoo.com Guest

  2. Similar Questions and Discussions

    1. DataList's EditCommand not being raised
      I am attempting to raise the EditCommand event of a DataList when a Button in the ItemTemplate is clicked. Here is the HTML used for the...
    2. error in getting textbox value in EditCommand
      hi, i was trying to get the value of the textbox in the datagrid everytime the user click the edit button in the datagrid.. however i always...
    3. 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...
    4. 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'...
    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: Stumped on dropdownlist, editcommand

    There is a good sample here at:-
    [url]http://www.4guysfromrolla.com/webtech/050801-1.shtml[/url]
    Patrick

    <jhcorey@yahoo.com> wrote in message
    news:1131395278.366298.113620@g14g2000cwa.googlegr oups.com...
    > I've been googling this and know it's been covered often, but I can't
    > get mine to work.
    >
    > I'm using a dropdown list when editing the record in the datagrid.
    > I'm using an arraylist (although I'm willing to change) to populate the
    > dropdown.
    >
    > The problem is selecting the item in the dropdown that corresponds to
    > the current record's value.
    >
    > I have the code below. I'm looking for the simplest way to select the
    > correct value in the dropdownlist. I notice in the OnItemDataBound I
    > have to cast the item cells to textboxes when the item is being edited,
    > but I'm not sure how to find the value I need.
    >
    >
    > private void dg_Columns_Edit(object source,
    > System.Web.UI.WebControls.DataGridCommandEventArgs e)
    > {
    > dg_Columns.EditItemIndex = e.Item.ItemIndex;
    > rptDataTypes = new ArrayList();
    > rptDataTypes.Add("DESC");
    > rptDataTypes.Add("ASC");
    >
    > FillColumnGrid();
    > DropDownList dl =
    >
    ((DropDownList)dg_Columns.Items[e.Item.ItemIndex].Cells[5].FindControl("ddlS
    ortDir"));
    > dl.DataSource = rptDataTypes;
    > dl.DataBind();
    >
    >
    > }
    >

    Patrick.O.Ige 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