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
1 Comment
LVL 96

Accepted Solution

Bob Learned earned 500 total points
Comment Utility
Did you find a solution?


Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now