troubleshooting Question

How do I populate a dropdownlist based on the value of another dropdownlist in an edit item template for a detailsview?

Avatar of bhorlings
bhorlingsFlag for United States of America asked on
.NET ProgrammingASP.NETWeb Applications
1 Comment1 Solution1615 ViewsLast Modified:
I have a dropdownlist that I need to base on the selected value of another dropdownlist in the edit template of a details view. Below is my source and I have nothing in the code behind.

<%@ Page Language="VB" MasterPageFile="~/_m/leftnavbar_maint_tasks.master" AutoEventWireup="false" CodeFile="task_admin.aspx.vb" Inherits="maint_task_admin" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphMain" Runat="Server">
<script language="javascript" type="text/javascript">

</script>

   <asp:scriptmanager id="ScriptManager1" runat="server"></asp:scriptmanager>
   <h2>Unassigned Tasks</h2>
   <asp:detailsview id="dtlUnassignedTasks" runat="server" allowpaging="True" autogeneraterows="False"
        datakeynames="id" datasourceid="srcUnassignedTasks" defaultmode="Edit" height="50px"
        width="486px" cellspacing="-1">
        <fields>
            <asp:boundfield datafield="id" headertext="id" insertvisible="False" readonly="True"
                sortexpression="id" visible="False" />
            <asp:boundfield datafield="subject" headertext="subject" sortexpression="subject" />
            <asp:boundfield datafield="requestor" headertext="requestor" sortexpression="requestor" />
            <asp:boundfield datafield="requestor_email" headertext="requestor_email" sortexpression="requestor_email" />
            <asp:boundfield datafield="machine" headertext="machine" sortexpression="machine" />
            <asp:templatefield headertext="tech_id" sortexpression="tech_id">
                <edititemtemplate>
                    <asp:dropdownlist id="drpTech" runat="server" datasourceid="srcTechs" datatextfield="tech_name"
                        datavaluefield="id" selectedvalue='<%# Bind("tech_id") %>' appenddatabounditems="True">
                    </asp:dropdownlist>
                </edititemtemplate>
            </asp:templatefield>
            <asp:templatefield headertext="priority_id" sortexpression="priority_id">
                <edititemtemplate>
                    <asp:dropdownlist id="drpPriority" runat="server" datasourceid="srcPriorities"
                        datatextfield="desc" datavaluefield="id" selectedvalue='<%# Bind("priority_id") %>' autopostback="True" onselectedindexchanged="drpPriority_SelectedIndexChanged">
                    </asp:dropdownlist>
                </edititemtemplate>
            </asp:templatefield>
            <asp:templatefield headertext="sub_priority_id" sortexpression="sub_priority_id">
                <edititemtemplate>
                    <asp:dropdownlist id="drpSubPriority" runat="server" datasourceid="srcSubPriority"
                        datatextfield="desc" datavaluefield="id">
                    </asp:dropdownlist>
                </edititemtemplate>
            </asp:templatefield>
            <asp:templatefield headertext="status_id" sortexpression="status_id">
                <edititemtemplate>
                    <asp:dropdownlist id="drpStatus" runat="server" datasourceid="srcStatus"
                        datatextfield="desc" datavaluefield="id" selectedvalue='<%# Bind("status_id") %>'>
                    </asp:dropdownlist>
                </edititemtemplate>
            </asp:templatefield>
            <asp:templatefield headertext="date_req" sortexpression="date_req">
                <edititemtemplate>
                    <asp:textbox id="txtDateReq" runat="server" text='<%# Bind("date_req", "{0:d}") %>' readonly="True"></asp:textbox>
                </edititemtemplate>
            </asp:templatefield>
            <asp:templatefield headertext="date_start" sortexpression="date_start">
                <edititemtemplate>
                    <asp:textbox id="txtDateStart" runat="server" text='<%# Bind("date_start") %>' ></asp:textbox>
                    <img id="imgCalDateStart" src="../_i/calendar.png" language="javascript" onclick="return IMG1_onclick()" />
                    <ajaxtoolkit:calendarextender id="calextDateStart" runat="server" targetcontrolid="txtDateStart" popupbuttonid="imgCalDateStart">
                    </ajaxtoolkit:calendarextender>
                </edititemtemplate>
            </asp:templatefield>
            <asp:templatefield headertext="date_due" sortexpression="date_due">
                <edititemtemplate>
                    <asp:textbox id="txtDateDue" runat="server" text='<%# Bind("date_due", "{0:d}") %>'></asp:textbox>
                    <img id="imgCalDateDue" src="../_i/calendar.png" />
                    <ajaxtoolkit:calendarextender id="calextDateDue" runat="server" popupbuttonid="imgCalDateDue"
                        targetcontrolid="txtDateDue">
                    </ajaxtoolkit:calendarextender>
                </edititemtemplate>
            </asp:templatefield>
            <asp:commandfield showeditbutton="True" />
        </fields>
        <emptydatatemplate>
            There are no more tasks that need to be assigned.
        </emptydatatemplate>
    </asp:detailsview>
   
    <asp:sqldatasource id="srcUnassignedTasks" runat="server" conflictdetection="CompareAllValues"
        connectionstring="<%$ ConnectionStrings:conMaintTasks %>"
        oldvaluesparameterformatstring="original_{0}" selectcommand="SELECT     task.id, task.subject, task.requestor, task.requestor_email, task.machine, task.tech_id, tech.first_name + ' ' + tech.last_name AS tech_name, &#13;&#10;                      task.priority_id, priority.[desc] AS priority, task.sub_priority_id, sub_priority.[desc] AS sub_priority, task.status_id, status.[desc] AS status, &#13;&#10;                      task.date_req, task.date_start, task.date_due&#13;&#10;FROM         task LEFT OUTER JOIN&#13;&#10;                      status ON task.status_id = status.id LEFT OUTER JOIN&#13;&#10;                      sub_priority ON task.sub_priority_id = sub_priority.id LEFT OUTER JOIN&#13;&#10;                      priority ON task.priority_id = priority.id LEFT OUTER JOIN&#13;&#10;                      tech ON task.tech_id = tech.id&#13;&#10;WHERE     (task.status_id = 1)"
        updatecommand="UPDATE [task] SET [subject] = @subject, [requestor] = @requestor, [requestor_email] = @requestor_email, [machine] = @machine, [tech_id] = @tech_id, [priority_id] = @priority_id, [sub_priority_id] = @sub_priority_id, [status_id] = @status_id, [date_req] = @date_req, [date_start] = @date_start, [date_due] = @date_due WHERE [id] = @original_id">
        <updateparameters>
            <asp:parameter name="subject" type="String" />
            <asp:parameter name="requestor" type="String" />
            <asp:parameter name="requestor_email" type="String" />
            <asp:parameter name="machine" type="String" />
            <asp:parameter name="tech_id" type="Int32" />
            <asp:parameter name="priority_id" type="Int32" />
            <asp:parameter name="sub_priority_id" type="Int32" />
            <asp:parameter name="status_id" type="Int32" />
            <asp:parameter name="date_req" type="DateTime" />
            <asp:parameter name="date_start" type="DateTime" />
            <asp:parameter name="date_due" type="DateTime" />
            <asp:parameter name="original_id" type="Int32" />
        </updateparameters>
    </asp:sqldatasource>
    <asp:sqldatasource id="srcTechs" runat="server" connectionstring="<%$ ConnectionStrings:conMaintTasks %>"
        selectcommand="SELECT id, first_name + ' ' + last_name AS tech_name FROM tech union select null, null"></asp:sqldatasource>
    <asp:sqldatasource id="srcPriorities" runat="server" connectionstring="<%$ ConnectionStrings:conMaintTasks %>"
        selectcommand="SELECT id, [desc] FROM priority union select null, null"></asp:sqldatasource>
    <asp:sqldatasource id="srcStatus" runat="server" connectionstring="<%$ ConnectionStrings:conMaintTasks %>"
        selectcommand="SELECT [id], [desc] FROM [status]union select null, null"></asp:sqldatasource>
    <asp:sqldatasource id="srcSubPriority" runat="server" connectionstring="<%$ ConnectionStrings:conMaintTasks %>"
        selectcommand="SELECT id, [desc], priority_id FROM sub_priority">
    </asp:sqldatasource>
</asp:Content>

ASKER CERTIFIED SOLUTION
nisarkhan

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros