Link to home
Start Free TrialLog in
Avatar of keithwilson1
keithwilson1Flag for United States of America

asked on

Updating a GridView that contain a dropdownlist using a Update SqlDataSource

I have created a aspx page that contains a gridview with a dropdownlist that will be updated for every row in the gridview.  I want to know the correct parameter values to use when setting up the sqldatasource.  I will be using a button to initate the process.  Below is my html.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="AssignRole.aspx.vb" Inherits="AssignRole" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="lblSSCampus" runat="server" Text="SS Campus:"></asp:Label>
        <asp:DropDownList ID="ddlSSCampus" runat="server" DataSourceID="SSCampusSqlDataSource" DataTextField="SchoolName" DataValueField="SchoolId">
        </asp:DropDownList><br />
        <br />
        <asp:Label ID="lblReqPosition" runat="server" Text="Requested Position:"></asp:Label>
        <asp:DropDownList ID="ddlPosition" runat="server" DataSourceID="PositionSqlDataSource" DataTextField="Name" DataValueField="PositionId">
        </asp:DropDownList><br />
        <br />
        <br />
        <asp:GridView ID="grdAssignRole" runat="server" AutoGenerateColumns="False" DataSourceID="RoleAssignmentSqlDataSource">
            <Columns>
                <asp:TemplateField HeaderText="Role" SortExpression="Role_name">
                    <EditItemTemplate>
                        <asp:DropDownList ID="ddlAssignRole" runat="server" DataSourceID="StatusSqlDataSource"
                            DataTextField="Role_Name" DataValueField="ID" SelectedIndex='<%#Bind("Id") %>'>
                        </asp:DropDownList>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblRole" runat="server" Text='<%# Bind("Role_name")
                    %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="applicationId" HeaderText="applicationId" InsertVisible="False"
                    ReadOnly="True" SortExpression="applicationId" Visible="false" />
                <asp:BoundField DataField="FacultyName" HeaderText="FacultyName" ReadOnly="True"
                    SortExpression="FacultyName" />
                <asp:BoundField DataField="FacultyId" HeaderText="FacultyId" SortExpression="FacultyId" />
                <asp:BoundField DataField="StatusId" HeaderText="StatusId" SortExpression="StatusId" Visible="false" />
                <asp:BoundField DataField="Position" HeaderText="Position" SortExpression="Position" />
                <asp:BoundField DataField="SchoolName" HeaderText="Home Campus" ReadOnly="True" SortExpression="SchoolName" />
                <asp:BoundField DataField="OrderNo" HeaderText="OrderNo" SortExpression="OrderNo" Visible="false" />
                <asp:BoundField DataField="limitedAvailability" HeaderText="limitedAvailability"
                    ReadOnly="True" SortExpression="limitedAvailability" Visible="false" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SSCampusSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SummerSchoolConnectionString %>"
            SelectCommand="ssrSP_getAllSSCampuses" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:Parameter DefaultValue="4" Name="yrId" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
   
    </div>
        <asp:SqlDataSource ID="PositionSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SummerSchoolConnectionString %>"
            SelectCommand="refSP_getPositions" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:Parameter DefaultValue="0" Name="appId" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="RoleAssignmentSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SummerSchoolConnectionString %>"
            SelectCommand="ssrSP_getRoleAssignments" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:Parameter DefaultValue="4" Name="yrId" Type="Int32" />
                <asp:ControlParameter ControlID="ddlSSCampus" DefaultValue="" Name="SSSchoolId" PropertyName="SelectedValue"
                    Type="String" />
                <asp:ControlParameter ControlID="ddlPosition" Name="Position" PropertyName="SelectedValue"
                    Type="Int32" />
                <asp:Parameter DefaultValue="0" Name="Status" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
            <asp:SqlDataSource ID="RolesSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SummerSchoolConnectionString %>"
            SelectCommand="ssrSP_getRoles" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:Parameter DefaultValue="1" Name="SSRole" Type="Int32" />
                <asp:Parameter DefaultValue="0" Name="admin" Type="Int32" />
                <asp:Parameter DefaultValue="4" Name="yrId" Type="Int32" />
                <asp:Parameter DefaultValue="''" Name="schCode" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="AssignRolesSqlDataSource" runat="server" UpdateCommand="ssrSP_assignRole" UpdateCommandType="StoredProcedure">
            <UpdateParameters>
                <asp:ControlParameter ControlID="grdAssignRole" Name="applicationId" PropertyName="Columns" />
                <asp:ControlParameter ControlID="grdAssignRole" Name="ddlAssignRole.SelectedValue" PropertyName="Columns" />
            </UpdateParameters>
        </asp:SqlDataSource>
    </form>
</body>
</html>



ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial