Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Gridview with dropdown not updating in custom moduleGridview with dropdown not updating in custom module
Previous
 
Next
New Post
3/19/2009 4:36 PM
 

I have a custom module I've been playing around with for some time now and I can't seem to get the update to work. When I click update in the gridview edit template  nothing happens but a page refresh, no data changes. Not even an error. Anyone have any ideas why? I'm a little new to this stuff. Here's my code:

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Sports.ascx.vb" Inherits="OnTargetJobs_Sports" %>

<asp:SqlDataSource ID="SqlTeams" runat="server" ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>" SelectCommand="SELECT [TeamId], [TeamName] FROM [gra_SportScheduleTeams]"></asp:SqlDataSource>
<div style="width: 200px; height: 20px; background: orange; font: normal normal bold 12px arial; color: White; line-height: 20px; padding-left: 4px;">
Teams</div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="TeamId" DataSourceID="SqlTeams" GridLines="None" ShowHeader="False">
    <Columns>
        <asp:TemplateField HeaderText="TeamName" SortExpression="TeamName">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("TeamName") %>'></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:LinkButton ID="LinkButton1111" runat="server" OnClientClick="show('GridView22');" CausesValidation="False" CommandName="Select" Text=""><asp:Label ID="Label1" runat="server" Text='<%# Bind("TeamName") %>'></asp:Label></asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>


<asp:SqlDataSource ID="SqlMembers" runat="server" ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>" FilterExpression="TeamID='{0}'" SelectCommand="SELECT gra_SportsTeamMembers.UserID, gra_SportsTeamMembers.TeamId, Users.UserID, Users.DisplayName FROM [gra_SportsTeamMembers], Users WHERE gra_SportsTeamMembers.UserID=Users.Userid">
    <FilterParameters>
        <asp:ControlParameter ControlID="GridView1" Name="UserID" PropertyName="SelectedValue" />
    </FilterParameters>
</asp:SqlDataSource>
<div style="width: 200px; height: 20px; background: orange; font: normal normal bold 12px arial; color: White; line-height: 20px; padding-left: 4px;">
Team Members</div>
<div id="GridView22">
<asp:GridView ID="GridView2" runat="server"  AutoGenerateColumns="False" DataSourceID="SqlMembers" DataKeyNames="UserID" CellPadding="4" CellSpacing="1" GridLines="None" ShowHeader="False" Width="280px">
    <Columns>
        <asp:TemplateField HeaderText="DisplayName" SortExpression="DisplayName">
            <ItemTemplate>
                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Select" Text=""><asp:Label ID="Label1" runat="server" Text='<%# Bind("DisplayName") %>'></asp:Label></asp:LinkButton>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("DisplayName") %>'></asp:TextBox>
            </EditItemTemplate>
        </asp:TemplateField>
    </Columns>
    <HeaderStyle BackColor="Orange" Font-Names="Arial" Font-Size="X-Small" ForeColor="White" />
</asp:GridView>
</div>


<asp:SqlDataSource ID="SqlMember" runat="server" ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>" FilterExpression="UserID='{0}'" SelectCommand="SELECT * FROM [Users]">
    <FilterParameters>
        <asp:ControlParameter ControlID="GridView2" Name="UserID" PropertyName="SelectedValue" />
    </FilterParameters>
</asp:SqlDataSource>
<div style="width: 200px; height: 20px; background: orange; font: normal normal bold 12px arial; color: White; line-height: 20px; padding-left: 4px;">
Member Profile</div>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataSourceID="SqlMember" DataKeyNames="UserID" CellPadding="4" CellSpacing="1" Font-Names="Arial" Font-Size="X-Small" GridLines="None" AutoGenerateEditButton="True">
    <FieldHeaderStyle BackColor="Orange" ForeColor="White" Height="12px" Width="100px" />
    <Fields>
        <asp:BoundField DataField="DisplayName" HeaderText="DisplayName" SortExpression="DisplayName" />
        <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />   
    </Fields>
    <HeaderStyle BorderStyle="None" />
</asp:DetailsView>
<br />


<asp:SqlDataSource ID="SqlMember2" runat="server" ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>" SelectCommand="SELECT u.DisplayName, u.UserID, p.PropertyName, up.PropertyValue FROM dbo.Users u INNER JOIN dbo.UserProfile up ON u.UserID = up.UserID INNER JOIN dbo.ProfilePropertyDefinition p ON up.PropertyDefinitionId = p.PropertyDefinitionId" FilterExpression="UserID='{0}'">
    <FilterParameters>
        <asp:ControlParameter ControlID="GridView2" Name="UserID" PropertyName="SelectedValue" />
    </FilterParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False" DataKeyNames="UserID" DataSourceID="SqlMember2" ShowHeader="False" Font-Names="Arial" Font-Size="X-Small" GridLines="None" CellPadding="4" CellSpacing="1" AutoGenerateEditButton="True">
    <Columns>     
        <asp:TemplateField HeaderText="PropertyName" SortExpression="PropertyName">
            <ItemTemplate>
                <asp:Label ID="Label1" runat="server" Text='<%# Bind("PropertyName") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("PropertyName") %>'></asp:TextBox>
            </EditItemTemplate>
            <ItemStyle BackColor="Orange" ForeColor="White" Width="100px" />
        </asp:TemplateField>
        <asp:TemplateField HeaderText="PropertyValue" SortExpression="PropertyValue">
            <ItemTemplate>
                <asp:Label ID="Label2" runat="server" Text='<%# Bind("PropertyValue") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("PropertyValue") %>'></asp:TextBox>
            </EditItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
<br />


<asp:SqlDataSource ID="SqlTeamMembers" runat="server" ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>" SelectCommand="SELECT sst.TeamID, sst.TeamName, u.DisplayName, stm.UserID, stm.TeamID FROM dbo.gra_SportScheduleTeams sst, dbo.Users u, dbo.gra_SportsTeamMembers stm WHERE stm.TeamID = sst.TeamId AND u.UserID = stm.UserID"
UpdateCommand="UPDATE dbo.gra_SportsTeamMembers SET gra_SportsTeamMembers.TeamID = @TeamID WHERE gra_SportsTeamMembers.UserID = @UserID" >
</asp:SqlDataSource>
<asp:GridView ID="GridView4" runat="server" DataSourceID="SqlTeamMembers" DataKeyNames="TeamID, UserID" AutoGenerateColumns="False" GridLines="None">
    <Columns>
        <asp:TemplateField HeaderText="TeamName" SortExpression="TeamName">
            <EditItemTemplate>
                <asp:DropDownList ID="TeamMembers" DataSourceID="SqlTeams" DataValueField="TeamID" DataTextField="TeamName"
                AutoPostBack="false" OnSelectedIndexChanged="TeamsDropDownList_OnSelectedIndexChanged" RunAt="Server" />
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label2" runat="server" Text='<%# Bind("TeamName") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="DisplayName" SortExpression="DisplayName">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("DisplayName") %>'></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label1" runat="server" Text='<%# Bind("DisplayName") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField ShowHeader="False">
            <EditItemTemplate>
                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Update"></asp:LinkButton>
                &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit"></asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>


AND THE CODE BEHIND:


Partial Class OnTargetJobs_Sports
    Inherits System.Web.UI.UserControl
    Sub TeamsDropDownList_OnSelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
        GridView4.DataBind()
    End Sub
End Class
 

 
New Post
3/19/2009 7:35 PM
 

I figured out that nothing is happening because the SQL variables aren't declared. How do I pull the TeamID and UserID from the form into the SQL statement? I can't find anything on Google so far except VB code that composes the statements. I need to see statements like the SQLDataSources I'm using. I know I know, I probably should be using sprocs... or ObjectDataSource, but I'm not quite there yet.

EDIT: I tried entering some update parameters but still no luck. Says "Could not find control 'GridView4' in ControlParameter 'TeamID'."

    <UpdateParameters>
        <asp:ControlParameter ControlID="GridView4" PropertyName="TeamID" Name="TeamID" />
        <asp:ControlParameter ControlID="GridView4" PropertyName="UserID" Name="UserID" />
    </UpdateParameters>

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Gridview with dropdown not updating in custom moduleGridview with dropdown not updating in custom module


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out