Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Updating a GridView that contain a dropdownlist using a Update SqlDataSource

Posted on 2007-11-14
Medium Priority
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>
    <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 1000 total points
ID: 20327545
Did you find a solution?


Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

609 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