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>
<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