Updating a GridView that contain a dropdownlist using a Update SqlDataSource

Posted on 2007-11-14
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" "">

<html xmlns="" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
        <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">
                <asp:TemplateField HeaderText="Role" SortExpression="Role_name">
                        <asp:DropDownList ID="ddlAssignRole" runat="server" DataSourceID="StatusSqlDataSource"
                            DataTextField="Role_Name" DataValueField="ID" SelectedIndex='<%#Bind("Id") %>'>
                        <asp:Label ID="lblRole" runat="server" Text='<%# Bind("Role_name")
                <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" />
        <asp:SqlDataSource ID="SSCampusSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SummerSchoolConnectionString %>"
            SelectCommand="ssrSP_getAllSSCampuses" SelectCommandType="StoredProcedure">
                <asp:Parameter DefaultValue="4" Name="yrId" Type="Int32" />
        <asp:SqlDataSource ID="PositionSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SummerSchoolConnectionString %>"
            SelectCommand="refSP_getPositions" SelectCommandType="StoredProcedure">
                <asp:Parameter DefaultValue="0" Name="appId" Type="Int32" />
        <asp:SqlDataSource ID="RoleAssignmentSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SummerSchoolConnectionString %>"
            SelectCommand="ssrSP_getRoleAssignments" SelectCommandType="StoredProcedure">
                <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" />
            <asp:SqlDataSource ID="RolesSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SummerSchoolConnectionString %>"
            SelectCommand="ssrSP_getRoles" SelectCommandType="StoredProcedure">
                <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" />
        <asp:SqlDataSource ID="AssignRolesSqlDataSource" runat="server" UpdateCommand="ssrSP_assignRole" UpdateCommandType="StoredProcedure">
                <asp:ControlParameter ControlID="grdAssignRole" Name="applicationId" PropertyName="Columns" />
                <asp:ControlParameter ControlID="grdAssignRole" Name="ddlAssignRole.SelectedValue" PropertyName="Columns" />

Question by:keithwilson1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 96

Accepted Solution

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


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSIS Start 2 44
PowerShell:  Column widths won't expand 3 49
TFS 2015 Access denied. 1 30
Activating .NET Framework 3.5 and which option to choose 5 31
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

733 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