Solved

Updating a GridView that contain a dropdownlist using a Update SqlDataSource

Posted on 2007-11-14
1
1,392 Views
Last Modified: 2013-11-26
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>



0
Comment
Question by:keithwilson1
1 Comment
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 20327545
Did you find a solution?

Bob
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Get number of Files in Directory and Sub Directories 2 48
Firing an ASP.NET event on selection of a JQuery datepicker 4 30
Code enhancement 4 21
Groupbox Control ? 2 17
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question