how do i access a dropdownlists selected value in a datagrid edititemtemplate column from the select

Discussion in 'ASP .Net Datagrid Control' started by Dave M, Dec 14, 2004.

  1. Dave M

    Dave M Guest

    i am trying to trap the value of one dropdownlist (in a datagrid
    edititemtemplate column) at the time its selectedindexchanged event
    fires and use its value to query a db and rebind a second dropdownlist
    (in a second datagrid edititemtemplate column).

    here's my code:

    <td width="9"><asp:datagrid id="dgManageVehicles" runat="server"
    Width="472px" AutoGenerateColumns="False" CellSpacing="1"
    CellPadding="3" BackColor="White" BorderWidth="2px"
    BorderStyle="Ridge" BorderColor="White" AllowSorting="True"
    DataKeyField="VehicleID" Height="216px">
    <SelectedItemStyle Font-Bold="True" ForeColor="White"
    BackColor="#9471DE"></SelectedItemStyle>
    <EditItemStyle Font-Size="Smaller" Font-Names="Arial"
    BorderWidth="2px" ForeColor="Lime" BorderStyle="Double"
    BorderColor="Black" BackColor="Aqua"></EditItemStyle>
    <ItemStyle Font-Size="9px" Font-Names="Verdana"
    ForeColor="White" BackColor="Black"></ItemStyle>
    <HeaderStyle Font-Size="10px" Font-Names="Verdana"
    Font-Bold="True" ForeColor="#E7E7FF" BorderStyle="None"
    BackColor="Black"></HeaderStyle>
    <FooterStyle ForeColor="Black"
    BackColor="#C6C3C6"></FooterStyle>
    <Columns>
    <asp:BoundColumn Visible="False" DataField="DealerID"
    HeaderText="DealerID"></asp:BoundColumn>
    <asp:BoundColumn Visible="False" DataField="VehicleID"
    HeaderText="VehicleID"></asp:BoundColumn>
    <asp:TemplateColumn HeaderText="Make">
    <ItemTemplate>
    <asp:label id="Label1" runat="server"
    ForeColor="White" Font-Names="Verdana">
    <%# DataBinder.Eval(Container.DataItem,
    "VehicleMake") %>
    </asp:label>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:dropdownlist id=ddlEditMakes runat="server"
    Font-Names="Verdana" BackColor="White" Font-Size="10px"
    AutoPostBack="True" DataSource="<%# GetMakes %>"
    DataTextField="MakeDesc" DataValueField="MakeID"
    OnSelectedIndexChanged="MakeIndexChange_Command" SelectedIndex='<%#
    GetMakeSelIndex(DataBinder.Eval(Container.DataItem, "VehicleMake")) %>'
    >

    </asp:dropdownlist>
    </EditItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="Model">
    <ItemTemplate>
    <asp:label id="Label2" runat="server"
    ForeColor="White" Font-Names="Verdana">
    <%# DataBinder.Eval(Container.DataItem,
    "VehicleModel") %>
    </asp:label>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:dropdownlist id="ddlEditMakeModel"
    runat="server" Font-Names="Verdana" BackColor="White"
    DataTextField="MODEL_DESCRIPTION" DataSource='<%#
    GetMakeModels(DataBinder.Eval(Container.DataItem, "VehicleMake")) %>'
    AutoPostBack="False" Font-Size="10px">
    </asp:dropdownlist>
    </EditItemTemplate>
    </asp:TemplateColumn>
    <asp:BoundColumn DataField="RegYear"
    HeaderText="Registration Year"></asp:BoundColumn>
    <asp:BoundColumn DataField="Engine_CC"
    HeaderText="Engine Size (cc)"></asp:BoundColumn>
    <asp:BoundColumn DataField="Body_desc"
    HeaderText="Body Type"></asp:BoundColumn>
    <asp:BoundColumn DataField="Colour"
    HeaderText="Colour"></asp:BoundColumn>
    <asp:BoundColumn DataField="Mileage"
    HeaderText="Mileage"></asp:BoundColumn>
    <asp:TemplateColumn HeaderText="New">
    <ItemTemplate>
    <asp:Checkbox id=chkIsNew runat="server"
    Checked='<%# DataBinder.Eval(Container.DataItem, "IsNew") %>'
    enabled="false">
    </asp:Checkbox>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:Checkbox id=ChkUPDIsNew runat="server"
    Checked='<%# DataBinder.Eval(Container.DataItem, "IsNew") %>'>
    </asp:Checkbox>
    </EditItemTemplate>
    </asp:TemplateColumn>
    <asp:BoundColumn DataField="Carfinderprice"
    HeaderText="Car Finder Price"></asp:BoundColumn>
    <asp:BoundColumn DataField="standardprice"
    HeaderText="Price"></asp:BoundColumn>
    <asp:BoundColumn DataField="lastupdated"
    ReadOnly="True" HeaderText="Last Updated"></asp:BoundColumn>
    <asp:ButtonColumn Text="Delete"
    ButtonType="PushButton" CommandName="Delete"></asp:ButtonColumn>
    <asp:EditCommandColumn ButtonType="PushButton"
    UpdateText="Update" CancelText="Cancel"
    EditText="Edit"></asp:EditCommandColumn>
    </Columns>
    <PagerStyle HorizontalAlign="Right" ForeColor="Black"
    BackColor="#C6C3C6"></PagerStyle>
    </asp:datagrid></td>

    Ive Got a custom event call :-

    OnSelectedIndexChanged="MakeIndexChange_Command"

    Q, what 'eventargs' do i need to pass to trap the selected value of the
    first dropdown from the datagrid and use it to rebind the second
    dropdown?
     
    Dave M, Dec 14, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vishnu
    Replies:
    1
    Views:
    1,214
    Patrick.O.Ige
    Mar 25, 2006
  2. =?Utf-8?B?Tkg=?=
    Replies:
    2
    Views:
    29,322
    =?Utf-8?B?Tkg=?=
    Mar 27, 2006
  3. Greg Smith
    Replies:
    0
    Views:
    541
    Greg Smith
    Apr 12, 2007
  4. Zach Wells

    Setting field value in EditItemTemplate column

    Zach Wells, Apr 6, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    186
    Zach Wells
    Apr 6, 2004
  5. Greg Smith
    Replies:
    0
    Views:
    161
    Greg Smith
    Apr 12, 2007
Loading...

Share This Page