ASP.NET DetailsView Update doesn't work - asp.net

I use all data BoundField in DetailsView from SQL Server. I get the correct display, then I click Edit, then edit some dropdownlist with SQLDataSource and some textboxes. Then I click Update, nothing happen, still same old value and no error. Anyone know why it doesn't work? Here my code,
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="DatabaseName,ServerName,Instance" DataSourceID="SqlDataSource1" Height="50px" Width="125px">
<Fields>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowHeader="True" ShowInsertButton="True" />
<asp:BoundField DataField="DatabaseName" HeaderText="DatabaseName" ReadOnly="True" SortExpression="DatabaseName" />
<asp:TemplateField HeaderText="ServerName" SortExpression="ServerName">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("ServerName") %>'></asp:Label>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ServerName") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("ServerName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="WorkProcess" SortExpression="WorkProcess">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="workprocess" DataTextField="WorkProcess" DataValueField="WorkProcess">
</asp:DropDownList>
<asp:SqlDataSource ID="workprocess" runat="server" ConnectionString="<%$ ConnectionStrings:Database_Shared_NotebookConnectionString %>" SelectCommand="SELECT [WorkProcess] FROM [tblWorkProcess]"></asp:SqlDataSource>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="DropDownList8" runat="server" DataSourceID="workprocess" DataTextField="WorkProcess" DataValueField="WorkProcess">
</asp:DropDownList>
<asp:SqlDataSource ID="workprocess" runat="server" ConnectionString="<%$ ConnectionStrings:Database_Shared_NotebookConnectionString %>" SelectCommand="SELECT [WorkProcess] FROM [tblWorkProcess]"></asp:SqlDataSource>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("WorkProcess") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Primary_DBA" SortExpression="Primary_DBA">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="userid" DataTextField="UserID" DataValueField="UserID">
</asp:DropDownList>
<asp:SqlDataSource ID="userid" runat="server" ConnectionString="<%$ ConnectionStrings:Database_Shared_NotebookConnectionString %>" SelectCommand="SELECT [UserID] FROM [tblDBA]"></asp:SqlDataSource>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="DropDownList9" runat="server" DataSourceID="userid" DataTextField="UserID" DataValueField="UserID">
</asp:DropDownList>
<asp:SqlDataSource ID="userid" runat="server" ConnectionString="<%$ ConnectionStrings:Database_Shared_NotebookConnectionString %>" SelectCommand="SELECT [UserID] FROM [tblDBA]"></asp:SqlDataSource>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("Primary_DBA") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TMLASGroupNumber" SortExpression="TMLASGroupNumber">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="TMLAS" DataTextField="TMLASGroupNumber" DataValueField="TMLASGroupNumber">
</asp:DropDownList>
<asp:SqlDataSource ID="TMLAS" runat="server" ConnectionString="<%$ ConnectionStrings:Database_Shared_NotebookConnectionString %>" SelectCommand="SELECT [TMLASGroupNumber] FROM [tblTM_LAS]"></asp:SqlDataSource>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="DropDownList10" runat="server" DataSourceID="TMLAS" DataTextField="TMLASGroupNumber" DataValueField="TMLASGroupNumber">
</asp:DropDownList>
<asp:SqlDataSource ID="TMLAS" runat="server" ConnectionString="<%$ ConnectionStrings:Database_Shared_NotebookConnectionString %>" SelectCommand="SELECT [TMLASGroupNumber] FROM [tblTM_LAS]"></asp:SqlDataSource>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("TMLASGroupNumber") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TMASGroupNumber" SortExpression="TMASGroupNumber">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="TMAS" DataTextField="TMASGroupNumber" DataValueField="TMASGroupNumber">
</asp:DropDownList>
<asp:SqlDataSource ID="TMAS" runat="server" ConnectionString="<%$ ConnectionStrings:Database_Shared_NotebookConnectionString %>" SelectCommand="SELECT [TMASGroupNumber] FROM [tblTM_AS]"></asp:SqlDataSource>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="DropDownList11" runat="server" DataSourceID="TMAS" DataTextField="TMASGroupNumber" DataValueField="TMASGroupNumber">
</asp:DropDownList>
<asp:SqlDataSource ID="TMAS" runat="server" ConnectionString="<%$ ConnectionStrings:Database_Shared_NotebookConnectionString %>" SelectCommand="SELECT [TMASGroupNumber] FROM [tblTM_AS]"></asp:SqlDataSource>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("TMASGroupNumber") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="IIASGroupNumber" SortExpression="IIASGroupNumber">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList5" runat="server" DataSourceID="IIAS" DataTextField="IIASGroupNumber" DataValueField="IIASGroupNumber">
</asp:DropDownList>
<asp:SqlDataSource ID="IIAS" runat="server" ConnectionString="<%$ ConnectionStrings:Database_Shared_NotebookConnectionString %>" SelectCommand="SELECT [IIASGroupNumber] FROM [tblII_AS]"></asp:SqlDataSource>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="DropDownList12" runat="server" DataSourceID="IIAS" DataTextField="IIASGroupNumber" DataValueField="IIASGroupNumber">
</asp:DropDownList>
<asp:SqlDataSource ID="IIAS" runat="server" ConnectionString="<%$ ConnectionStrings:Database_Shared_NotebookConnectionString %>" SelectCommand="SELECT [IIASGroupNumber] FROM [tblII_AS]"></asp:SqlDataSource>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("IIASGroupNumber") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Architecture" SortExpression="Architecture">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList6" runat="server">
<asp:ListItem>BSN EAP</asp:ListItem>
<asp:ListItem>BSN NEA</asp:ListItem>
<asp:ListItem>BSNConnect.com</asp:ListItem>
<asp:ListItem>BSNDMZ.COM</asp:ListItem>
<asp:ListItem>Dow EAP</asp:ListItem>
<asp:ListItem>Dow NEA</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="DropDownList13" runat="server">
<asp:ListItem>BSN EAP</asp:ListItem>
<asp:ListItem>BSN NEA</asp:ListItem>
<asp:ListItem>BSNConnect.com</asp:ListItem>
<asp:ListItem>BSNDMZ.COM</asp:ListItem>
<asp:ListItem>Dow EAP</asp:ListItem>
<asp:ListItem>Dow NEA</asp:ListItem>
</asp:DropDownList>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Bind("Architecture") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Version" SortExpression="Version">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList7" runat="server">
<asp:ListItem>Oracle 11g</asp:ListItem>
<asp:ListItem>Oracle 11g R2</asp:ListItem>
<asp:ListItem>SQL Server 2008</asp:ListItem>
<asp:ListItem>SQL Server 2008 R2</asp:ListItem>
<asp:ListItem>SQL Server 2012</asp:ListItem>
<asp:ListItem>SQL Svr 2008 R2 SS%S</asp:ListItem>
<asp:ListItem>SQL Svr 2012 SS%S</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="DropDownList14" runat="server">
<asp:ListItem>Oracle 11g</asp:ListItem>
<asp:ListItem>Oracle 11g R2</asp:ListItem>
<asp:ListItem>SQL Server 2008</asp:ListItem>
<asp:ListItem>SQL Server 2008 R2</asp:ListItem>
<asp:ListItem>SQL Server 2012</asp:ListItem>
<asp:ListItem>SQL Svr 2008 R2 SS%S</asp:ListItem>
<asp:ListItem>SQL Svr 2012 SS%S</asp:ListItem>
</asp:DropDownList>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label8" runat="server" Text='<%# Bind("Version") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Quarter_Close_Vital" HeaderText="Quarter_Close_Vital" SortExpression="Quarter_Close_Vital" />
<asp:BoundField DataField="Business_Importance" HeaderText="Business_Importance" SortExpression="Business_Importance" />
<asp:BoundField DataField="Application_Number" HeaderText="Application_Number" SortExpression="Application_Number" />
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="Role_Based_Security_Doc" HeaderText="Role_Based_Security_Doc" SortExpression="Role_Based_Security_Doc" />
<asp:BoundField DataField="Max_Users" HeaderText="Max_Users" SortExpression="Max_Users" />
<asp:BoundField DataField="Storage_Requirements" HeaderText="Storage_Requirements" SortExpression="Storage_Requirements" />
<asp:BoundField DataField="Projected_Growth" HeaderText="Projected_Growth" SortExpression="Projected_Growth" />
<asp:BoundField DataField="Data_Owner_1" HeaderText="Data_Owner_1" SortExpression="Data_Owner_1" />
<asp:BoundField DataField="Data_Owner_2" HeaderText="Data_Owner_2" SortExpression="Data_Owner_2" />
<asp:BoundField DataField="SID" HeaderText="SID" SortExpression="SID" />
<asp:BoundField DataField="Alias" HeaderText="Alias" SortExpression="Alias" />
<asp:BoundField DataField="Instance" HeaderText="Instance" ReadOnly="True" SortExpression="Instance" />
<asp:BoundField DataField="Backup_Nodes" HeaderText="Backup_Nodes" SortExpression="Backup_Nodes" />
<asp:BoundField DataField="Portfolio_Lookup" HeaderText="Portfolio_Lookup" SortExpression="Portfolio_Lookup" />
<asp:BoundField DataField="Notes" HeaderText="Notes" SortExpression="Notes" />
<asp:BoundField DataField="ConnectionString" HeaderText="ConnectionString" SortExpression="ConnectionString" />
<asp:BoundField DataField="InstanceOccurence" HeaderText="InstanceOccurence" SortExpression="InstanceOccurence" />
<asp:BoundField DataField="OccurenceNormalState" HeaderText="OccurenceNormalState" SortExpression="OccurenceNormalState" />
<asp:BoundField DataField="SupportedFuntionalArea" HeaderText="SupportedFuntionalArea" SortExpression="SupportedFuntionalArea" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues" ConnectionString="<%$ ConnectionStrings:Database_Shared_NotebookConnectionString %>" DeleteCommand="DELETE FROM [tblDatabase] WHERE [DatabaseName] = #original_DatabaseName AND [ServerName] = #original_ServerName AND [Instance] = #original_Instance AND [WorkProcess] = #original_WorkProcess AND [Primary_DBA] = #original_Primary_DBA AND [TMLASGroupNumber] = #original_TMLASGroupNumber AND [TMASGroupNumber] = #original_TMASGroupNumber AND [IIASGroupNumber] = #original_IIASGroupNumber AND (([Architecture] = #original_Architecture) OR ([Architecture] IS NULL AND #original_Architecture IS NULL)) AND (([Version] = #original_Version) OR ([Version] IS NULL AND #original_Version IS NULL)) AND (([Quarter_Close_Vital] = #original_Quarter_Close_Vital) OR ([Quarter_Close_Vital] IS NULL AND #original_Quarter_Close_Vital IS NULL)) AND (([Business_Importance] = #original_Business_Importance) OR ([Business_Importance] IS NULL AND #original_Business_Importance IS NULL)) AND (([Application_Number] = #original_Application_Number) OR ([Application_Number] IS NULL AND #original_Application_Number IS NULL)) AND (([Description] = #original_Description) OR ([Description] IS NULL AND #original_Description IS NULL)) AND (([Role_Based_Security_Doc] = #original_Role_Based_Security_Doc) OR ([Role_Based_Security_Doc] IS NULL AND #original_Role_Based_Security_Doc IS NULL)) AND (([Max_Users] = #original_Max_Users) OR ([Max_Users] IS NULL AND #original_Max_Users IS NULL)) AND (([Storage_Requirements] = #original_Storage_Requirements) OR ([Storage_Requirements] IS NULL AND #original_Storage_Requirements IS NULL)) AND (([Projected_Growth] = #original_Projected_Growth) OR ([Projected_Growth] IS NULL AND #original_Projected_Growth IS NULL)) AND (([Data_Owner_1] = #original_Data_Owner_1) OR ([Data_Owner_1] IS NULL AND #original_Data_Owner_1 IS NULL)) AND (([Data_Owner_2] = #original_Data_Owner_2) OR ([Data_Owner_2] IS NULL AND #original_Data_Owner_2 IS NULL)) AND (([SID] = #original_SID) OR ([SID] IS NULL AND #original_SID IS NULL)) AND (([Alias] = #original_Alias) OR ([Alias] IS NULL AND #original_Alias IS NULL)) AND (([Backup_Nodes] = #original_Backup_Nodes) OR ([Backup_Nodes] IS NULL AND #original_Backup_Nodes IS NULL)) AND (([Portfolio_Lookup] = #original_Portfolio_Lookup) OR ([Portfolio_Lookup] IS NULL AND #original_Portfolio_Lookup IS NULL)) AND (([Notes] = #original_Notes) OR ([Notes] IS NULL AND #original_Notes IS NULL)) AND (([ConnectionString] = #original_ConnectionString) OR ([ConnectionString] IS NULL AND #original_ConnectionString IS NULL)) AND (([InstanceOccurence] = #original_InstanceOccurence) OR ([InstanceOccurence] IS NULL AND #original_InstanceOccurence IS NULL)) AND (([OccurenceNormalState] = #original_OccurenceNormalState) OR ([OccurenceNormalState] IS NULL AND #original_OccurenceNormalState IS NULL)) AND (([SupportedFuntionalArea] = #original_SupportedFuntionalArea) OR ([SupportedFuntionalArea] IS NULL AND #original_SupportedFuntionalArea IS NULL))" InsertCommand="INSERT INTO [tblDatabase] ([DatabaseName], [ServerName], [WorkProcess], [Primary_DBA], [TMLASGroupNumber], [TMASGroupNumber], [IIASGroupNumber], [Architecture], [Version], [Quarter_Close_Vital], [Business_Importance], [Application_Number], [Description], [Role_Based_Security_Doc], [Max_Users], [Storage_Requirements], [Projected_Growth], [Data_Owner_1], [Data_Owner_2], [SID], [Alias], [Instance], [Backup_Nodes], [Portfolio_Lookup], [Notes], [ConnectionString], [InstanceOccurence], [OccurenceNormalState], [SupportedFuntionalArea]) VALUES (#DatabaseName, #ServerName, #WorkProcess, #Primary_DBA, #TMLASGroupNumber, #TMASGroupNumber, #IIASGroupNumber, #Architecture, #Version, #Quarter_Close_Vital, #Business_Importance, #Application_Number, #Description, #Role_Based_Security_Doc, #Max_Users, #Storage_Requirements, #Projected_Growth, #Data_Owner_1, #Data_Owner_2, #SID, #Alias, #Instance, #Backup_Nodes, #Portfolio_Lookup, #Notes, #ConnectionString, #InstanceOccurence, #OccurenceNormalState, #SupportedFuntionalArea)" OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [tblDatabase]" UpdateCommand="UPDATE [tblDatabase] SET [WorkProcess] = #WorkProcess, [Primary_DBA] = #Primary_DBA, [TMLASGroupNumber] = #TMLASGroupNumber, [TMASGroupNumber] = #TMASGroupNumber, [IIASGroupNumber] = #IIASGroupNumber, [Architecture] = #Architecture, [Version] = #Version, [Quarter_Close_Vital] = #Quarter_Close_Vital, [Business_Importance] = #Business_Importance, [Application_Number] = #Application_Number, [Description] = #Description, [Role_Based_Security_Doc] = #Role_Based_Security_Doc, [Max_Users] = #Max_Users, [Storage_Requirements] = #Storage_Requirements, [Projected_Growth] = #Projected_Growth, [Data_Owner_1] = #Data_Owner_1, [Data_Owner_2] = #Data_Owner_2, [SID] = #SID, [Alias] = #Alias, [Backup_Nodes] = #Backup_Nodes, [Portfolio_Lookup] = #Portfolio_Lookup, [Notes] = #Notes, [ConnectionString] = #ConnectionString, [InstanceOccurence] = #InstanceOccurence, [OccurenceNormalState] = #OccurenceNormalState, [SupportedFuntionalArea] = #SupportedFuntionalArea WHERE [DatabaseName] = #original_DatabaseName AND [ServerName] = #original_ServerName AND [Instance] = #original_Instance AND [WorkProcess] = #original_WorkProcess AND [Primary_DBA] = #original_Primary_DBA AND [TMLASGroupNumber] = #original_TMLASGroupNumber AND [TMASGroupNumber] = #original_TMASGroupNumber AND [IIASGroupNumber] = #original_IIASGroupNumber AND (([Architecture] = #original_Architecture) OR ([Architecture] IS NULL AND #original_Architecture IS NULL)) AND (([Version] = #original_Version) OR ([Version] IS NULL AND #original_Version IS NULL)) AND (([Quarter_Close_Vital] = #original_Quarter_Close_Vital) OR ([Quarter_Close_Vital] IS NULL AND #original_Quarter_Close_Vital IS NULL)) AND (([Business_Importance] = #original_Business_Importance) OR ([Business_Importance] IS NULL AND #original_Business_Importance IS NULL)) AND (([Application_Number] = #original_Application_Number) OR ([Application_Number] IS NULL AND #original_Application_Number IS NULL)) AND (([Description] = #original_Description) OR ([Description] IS NULL AND #original_Description IS NULL)) AND (([Role_Based_Security_Doc] = #original_Role_Based_Security_Doc) OR ([Role_Based_Security_Doc] IS NULL AND #original_Role_Based_Security_Doc IS NULL)) AND (([Max_Users] = #original_Max_Users) OR ([Max_Users] IS NULL AND #original_Max_Users IS NULL)) AND (([Storage_Requirements] = #original_Storage_Requirements) OR ([Storage_Requirements] IS NULL AND #original_Storage_Requirements IS NULL)) AND (([Projected_Growth] = #original_Projected_Growth) OR ([Projected_Growth] IS NULL AND #original_Projected_Growth IS NULL)) AND (([Data_Owner_1] = #original_Data_Owner_1) OR ([Data_Owner_1] IS NULL AND #original_Data_Owner_1 IS NULL)) AND (([Data_Owner_2] = #original_Data_Owner_2) OR ([Data_Owner_2] IS NULL AND #original_Data_Owner_2 IS NULL)) AND (([SID] = #original_SID) OR ([SID] IS NULL AND #original_SID IS NULL)) AND (([Alias] = #original_Alias) OR ([Alias] IS NULL AND #original_Alias IS NULL)) AND (([Backup_Nodes] = #original_Backup_Nodes) OR ([Backup_Nodes] IS NULL AND #original_Backup_Nodes IS NULL)) AND (([Portfolio_Lookup] = #original_Portfolio_Lookup) OR ([Portfolio_Lookup] IS NULL AND #original_Portfolio_Lookup IS NULL)) AND (([Notes] = #original_Notes) OR ([Notes] IS NULL AND #original_Notes IS NULL)) AND (([ConnectionString] = #original_ConnectionString) OR ([ConnectionString] IS NULL AND #original_ConnectionString IS NULL)) AND (([InstanceOccurence] = #original_InstanceOccurence) OR ([InstanceOccurence] IS NULL AND #original_InstanceOccurence IS NULL)) AND (([OccurenceNormalState] = #original_OccurenceNormalState) OR ([OccurenceNormalState] IS NULL AND #original_OccurenceNormalState IS NULL)) AND (([SupportedFuntionalArea] = #original_SupportedFuntionalArea) OR ([SupportedFuntionalArea] IS NULL AND #original_SupportedFuntionalArea IS NULL))">
<DeleteParameters>
<asp:Parameter Name="original_DatabaseName" Type="String" />
<asp:Parameter Name="original_ServerName" Type="String" />
<asp:Parameter Name="original_Instance" Type="String" />
<asp:Parameter Name="original_WorkProcess" Type="String" />
<asp:Parameter Name="original_Primary_DBA" Type="String" />
<asp:Parameter Name="original_TMLASGroupNumber" Type="Int32" />
<asp:Parameter Name="original_TMASGroupNumber" Type="Int32" />
<asp:Parameter Name="original_IIASGroupNumber" Type="Int32" />
<asp:Parameter Name="original_Architecture" Type="String" />
<asp:Parameter Name="original_Version" Type="String" />
<asp:Parameter Name="original_Quarter_Close_Vital" Type="String" />
<asp:Parameter Name="original_Business_Importance" Type="String" />
<asp:Parameter Name="original_Application_Number" Type="String" />
<asp:Parameter Name="original_Description" Type="String" />
<asp:Parameter Name="original_Role_Based_Security_Doc" Type="String" />
<asp:Parameter Name="original_Max_Users" Type="String" />
<asp:Parameter Name="original_Storage_Requirements" Type="String" />
<asp:Parameter Name="original_Projected_Growth" Type="String" />
<asp:Parameter Name="original_Data_Owner_1" Type="String" />
<asp:Parameter Name="original_Data_Owner_2" Type="String" />
<asp:Parameter Name="original_SID" Type="String" />
<asp:Parameter Name="original_Alias" Type="String" />
<asp:Parameter Name="original_Backup_Nodes" Type="String" />
<asp:Parameter Name="original_Portfolio_Lookup" Type="String" />
<asp:Parameter Name="original_Notes" Type="String" />
<asp:Parameter Name="original_ConnectionString" Type="String" />
<asp:Parameter Name="original_InstanceOccurence" Type="Decimal" />
<asp:Parameter Name="original_OccurenceNormalState" Type="String" />
<asp:Parameter Name="original_SupportedFuntionalArea" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="WorkProcess" Type="String" />
<asp:Parameter Name="Primary_DBA" Type="String" />
<asp:Parameter Name="TMLASGroupNumber" Type="Int32" />
<asp:Parameter Name="TMASGroupNumber" Type="Int32" />
<asp:Parameter Name="IIASGroupNumber" Type="Int32" />
<asp:Parameter Name="Architecture" Type="String" />
<asp:Parameter Name="Version" Type="String" />
<asp:Parameter Name="Quarter_Close_Vital" Type="String" />
<asp:Parameter Name="Business_Importance" Type="String" />
<asp:Parameter Name="Application_Number" Type="String" />
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="Role_Based_Security_Doc" Type="String" />
<asp:Parameter Name="Max_Users" Type="String" />
<asp:Parameter Name="Storage_Requirements" Type="String" />
<asp:Parameter Name="Projected_Growth" Type="String" />
<asp:Parameter Name="Data_Owner_1" Type="String" />
<asp:Parameter Name="Data_Owner_2" Type="String" />
<asp:Parameter Name="SID" Type="String" />
<asp:Parameter Name="Alias" Type="String" />
<asp:Parameter Name="Backup_Nodes" Type="String" />
<asp:Parameter Name="Portfolio_Lookup" Type="String" />
<asp:Parameter Name="Notes" Type="String" />
<asp:Parameter Name="ConnectionString" Type="String" />
<asp:Parameter Name="InstanceOccurence" Type="Decimal" />
<asp:Parameter Name="OccurenceNormalState" Type="String" />
<asp:Parameter Name="SupportedFuntionalArea" Type="String" />
<asp:Parameter Name="original_DatabaseName" Type="String" />
<asp:Parameter Name="original_ServerName" Type="String" />
<asp:Parameter Name="original_Instance" Type="String" />
<asp:Parameter Name="original_WorkProcess" Type="String" />
<asp:Parameter Name="original_Primary_DBA" Type="String" />
<asp:Parameter Name="original_TMLASGroupNumber" Type="Int32" />
<asp:Parameter Name="original_TMASGroupNumber" Type="Int32" />
<asp:Parameter Name="original_IIASGroupNumber" Type="Int32" />
<asp:Parameter Name="original_Architecture" Type="String" />
<asp:Parameter Name="original_Version" Type="String" />
<asp:Parameter Name="original_Quarter_Close_Vital" Type="String" />
<asp:Parameter Name="original_Business_Importance" Type="String" />
<asp:Parameter Name="original_Application_Number" Type="String" />
<asp:Parameter Name="original_Description" Type="String" />
<asp:Parameter Name="original_Role_Based_Security_Doc" Type="String" />
<asp:Parameter Name="original_Max_Users" Type="String" />
<asp:Parameter Name="original_Storage_Requirements" Type="String" />
<asp:Parameter Name="original_Projected_Growth" Type="String" />
<asp:Parameter Name="original_Data_Owner_1" Type="String" />
<asp:Parameter Name="original_Data_Owner_2" Type="String" />
<asp:Parameter Name="original_SID" Type="String" />
<asp:Parameter Name="original_Alias" Type="String" />
<asp:Parameter Name="original_Backup_Nodes" Type="String" />
<asp:Parameter Name="original_Portfolio_Lookup" Type="String" />
<asp:Parameter Name="original_Notes" Type="String" />
<asp:Parameter Name="original_ConnectionString" Type="String" />
<asp:Parameter Name="original_InstanceOccurence" Type="Decimal" />
<asp:Parameter Name="original_OccurenceNormalState" Type="String" />
<asp:Parameter Name="original_SupportedFuntionalArea" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>

I found out why it doesn't work.
When I replace textbox to dropdownlist, It wipes the databinding. I have to go to Edit DataBinding to set it target to specific column.
Before, it left it blank that is why it does not change anything.

Came across this question while searching for a solution for the same issue. The fix for me was to set the DataKeyNames property of the DetailsView to the primary key for the table.

Related

How to make new command work in gridview asp.net

I have a gridview, in the gridview task, I choose Edit Column-> Selected Fields->Command Field.select insert button to True. And the New link field appear, and I check the HTML Source,
look like necessary codes are there, but when I click on the "New" link field, no response at all, but update is ok for me, delete I have not tested yet.
Below are codes for the gridview and sqldatasource :
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="agreement_no,id" Font-Size="9pt" DataSourceID="SqlDataSource1" OnRowUpdated="GridView1_RowUpdated" OnRowUpdating="GridView1_RowUpdating" OnRowCreated="GridView1_RowCreated">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True"></asp:CommandField>
<asp:BoundField DataField="agreement_no" HeaderText="agreement_no" ReadOnly="True" SortExpression="agreement_no"></asp:BoundField>
<asp:TemplateField HeaderText="status" SortExpression="status">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" DataTextField="status" DataValueField="status" SelectedValue='<%# Bind("status") %>'>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:GPGConnectionString %>" SelectCommand="SELECT DISTINCT [status] FROM [deal_master]"></asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("status") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="sales_person" HeaderText="sales_person" SortExpression="sales_person"></asp:BoundField>
<asp:BoundField DataField="swap_carrier" HeaderText="swap_carrier" SortExpression="swap_carrier"></asp:BoundField>
<asp:BoundField DataField="start_pos" HeaderText="start_pos" SortExpression="start_pos"></asp:BoundField>
<asp:BoundField DataField="end_pos" HeaderText="end_pos" SortExpression="end_pos"></asp:BoundField>
<asp:BoundField DataField="swap_commitment" HeaderText="swap_commitment" SortExpression="swap_commitment"></asp:BoundField>
<asp:BoundField DataField="zone" HeaderText="zone" SortExpression="zone"></asp:BoundField>
<asp:BoundField DataField="target_minutes" HeaderText="target_minutes" SortExpression="target_minutes"></asp:BoundField>
<asp:BoundField DataField="target_sell_rate" HeaderText="target_sell_rate" SortExpression="target_sell_rate"></asp:BoundField>
<asp:BoundField DataField="target_buy_rate" HeaderText="target_buy_rate" SortExpression="target_buy_rate"></asp:BoundField>
<asp:BoundField ConvertEmptyStringToNull="false" DataField="supplier_interconnect" HeaderText="supplier_interconnect" SortExpression="supplier_interconnect"></asp:BoundField>
<asp:BoundField ConvertEmptyStringToNull="false" DataField="customer_interconnect" HeaderText="customer_interconnect" SortExpression="customer_interconnect"></asp:BoundField>
<asp:BoundField DataField="target_sales" HeaderText="target_sales" SortExpression="target_sales"></asp:BoundField>
<asp:BoundField DataField="target_cost" HeaderText="target_cost" SortExpression="target_cost"></asp:BoundField>
<asp:BoundField DataField="target_profit" HeaderText="target_profit" SortExpression="target_profit"></asp:BoundField>
<asp:BoundField DataField="lcr_zone" HeaderText="lcr_zone" SortExpression="lcr_zone"></asp:BoundField>
<asp:BoundField DataField="id" HeaderText="id" SortExpression="id" ReadOnly="True"></asp:BoundField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:GPGConnectionString %>" DeleteCommand="DELETE FROM [deal_master] WHERE [agreement_no] = #agreement_no AND [id] = #id" InsertCommand="INSERT INTO [deal_master] ([agreement_no], [status], [sales_person], [swap_carrier], [start_pos], [end_pos], [swap_commitment], [zone], [target_minutes], [target_sell_rate], [target_buy_rate], [supplier_interconnect], [customer_interconnect], [target_sales], [target_cost], [target_profit], [lcr_zone], [id]) VALUES (#agreement_no, #status, #sales_person, #swap_carrier, #start_pos, #end_pos, #swap_commitment, #zone, #target_minutes, #target_sell_rate, #target_buy_rate, #supplier_interconnect, #customer_interconnect, #target_sales, #target_cost, #target_profit, #lcr_zone, #id)" SelectCommand="SELECT [agreement_no], [status], [sales_person], [swap_carrier], [start_pos], [end_pos], [swap_commitment], [zone], [target_minutes], [target_sell_rate], [target_buy_rate], [supplier_interconnect], [customer_interconnect], [target_sales], [target_cost], [target_profit], [lcr_zone], [id] FROM [deal_master]" UpdateCommand="UPDATE [deal_master] SET [status] = #status, [sales_person] = #sales_person, [swap_carrier] = #swap_carrier, [start_pos] = #start_pos, [end_pos] = #end_pos, [swap_commitment] = #swap_commitment, [zone] = #zone, [target_minutes] = #target_minutes, [target_sell_rate] = #target_sell_rate, [target_buy_rate] = #target_buy_rate, [supplier_interconnect] = #supplier_interconnect, [customer_interconnect] = #customer_interconnect, [target_sales] = #target_sales, [target_cost] = #target_cost, [target_profit] = #target_profit, [lcr_zone] = #lcr_zone WHERE [agreement_no] = #agreement_no AND [id] = #id">
<DeleteParameters>
<asp:Parameter Name="agreement_no" Type="String" />
<asp:Parameter Name="id" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="agreement_no" Type="String" />
<asp:Parameter Name="status" Type="String" />
<asp:Parameter Name="sales_person" Type="String" />
<asp:Parameter Name="swap_carrier" Type="String" />
<asp:Parameter Name="start_pos" Type="Decimal" />
<asp:Parameter Name="end_pos" Type="Decimal" />
<asp:Parameter Name="swap_commitment" Type="String" />
<asp:Parameter Name="zone" Type="String" />
<asp:Parameter Name="target_minutes" Type="Decimal" />
<asp:Parameter Name="target_sell_rate" Type="Decimal" />
<asp:Parameter Name="target_buy_rate" Type="Decimal" />
<asp:Parameter Name="supplier_interconnect" Type="String" />
<asp:Parameter ConvertEmptyStringToNull="false" Name="customer_interconnect" Type="String" />
<asp:Parameter Name="target_sales" Type="Decimal" />
<asp:Parameter Name="target_cost" Type="Decimal" />
<asp:Parameter Name="target_profit" Type="Decimal" />
<asp:Parameter Name="lcr_zone" Type="String" />
<asp:Parameter Name="id" Type="Int32" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="status" Type="String" />
<asp:Parameter Name="sales_person" Type="String" />
<asp:Parameter Name="swap_carrier" Type="String" />
<asp:Parameter Name="start_pos" Type="Decimal" />
<asp:Parameter Name="end_pos" Type="Decimal" />
<asp:Parameter Name="swap_commitment" Type="String" />
<asp:Parameter Name="zone" Type="String" />
<asp:Parameter Name="target_minutes" Type="Decimal" />
<asp:Parameter Name="target_sell_rate" Type="Decimal" />
<asp:Parameter Name="target_buy_rate" Type="Decimal" />
<asp:Parameter ConvertEmptyStringToNull="false" Name="supplier_interconnect" Type="String" />
<asp:Parameter ConvertEmptyStringToNull="false" Name="customer_interconnect" Type="String" />
<asp:Parameter Name="target_sales" Type="Decimal" />
<asp:Parameter Name="target_cost" Type="Decimal" />
<asp:Parameter Name="target_profit" Type="Decimal" />
<asp:Parameter Name="lcr_zone" Type="String" />
<asp:Parameter Name="agreement_no" Type="String" />
<asp:Parameter Name="id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:GPGConnectionString %>" SelectCommand="SELECT DISTINCT [agreement_no] FROM [deal_master] ORDER BY [agreement_no]"></asp:SqlDataSource>
<br />
<br />
<div>
</div>
enter image description here
my question is : what is the actions or setting I missed?
I want to know what steps I missed?
My objective is : I want to click on the "New" linkfield then 1 empty row appear, then I input the value in the new created row and I can save it or cancel it
If you look at the documentation for the GridView control, it says:
Inserting records into the data source is not directly supported by the GridView control. However, it is possible to insert records by using the GridView control in conjunction with the DetailsView or FormView control. For more information, see DetailsView or FormView, respectively.
Additionally, the CommandField documentation states about the ShowInsertButton property:
This property applies only to data-bound controls that support insert operations, such as the DetailsView control.
So, you'll need to create your own form separately, or leverage a DetailsView or FormView. Or better yet: ditch Web Forms altogether if you can, as it's a dead platform, as I explain on my blog.

GridView is not displaying when page is loaded

Hello I am working on a project for school. I am building a page that has a DropDownList that is populated through a SQLDataSource. It displays the names of classes from a table in my database called 'COURSES', when one of the classes is selected a GridView is supposed to display data from tables 'STUDENTS' and 'GRADES'. When I make a selection the GridView does not display at all. I think the problem is in my WHERE clause of the SELECT command. Any help would be greatly appreciated!
Here is my aspx file:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="ClassStudentEdit.aspx.cs" Inherits="ClassStudentEdit" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Students</title>
<link type="text/css" rel="stylesheet" href="termproject.css" />
</head>
<body>
<form id="form1" runat="server">
<div id="main">
Course Name: <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="CourseName" DataValueField="CourseID"></asp:DropDownList>
<br />
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:PayablesConnectionString %>" SelectCommand="SELECT [CourseName], [CourseID] FROM [COURSES] ORDER BY [CourseName]"></asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2" DataKeyNames="CourseID" AllowPaging="True" AllowSorting="True">
<Columns>
<asp:CommandField ButtonType="Button" ShowSelectButton="True" />
<asp:BoundField DataField="StudentID" HeaderText="StudentID" SortExpression="StudentID" InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="Grade" HeaderText="Grade" SortExpression="Grade" />
</Columns>
</asp:GridView>
<br />
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:PayablesConnectionString %>" SelectCommand="SELECT COURSES.CourseID, GRADES.Grade, STUDENTS.StudentID, STUDENTS.Title, STUDENTS.FirstName, STUDENTS.LastName FROM COURSES INNER JOIN GRADES ON COURSES.CourseID = GRADES.CourseID INNER JOIN STUDENTS ON GRADES.StudentID = STUDENTS.StudentID WHERE (COURSES.CourseName = #CourseID)">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="CourseID" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" AutoGenerateRows="False" DataKeyNames="StudentID" DataSourceID="SqlDataSource3">
<Fields>
<asp:BoundField DataField="StudentID" HeaderText="StudentID" InsertVisible="False" ReadOnly="True" SortExpression="StudentID" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
<asp:CommandField ShowEditButton="True" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConflictDetection="CompareAllValues" ConnectionString="<%$ ConnectionStrings:PayablesConnectionString %>" DeleteCommand="DELETE FROM [STUDENTS] WHERE [StudentID] = #original_StudentID AND (([Title] = #original_Title) OR ([Title] IS NULL AND #original_Title IS NULL)) AND (([FirstName] = #original_FirstName) OR ([FirstName] IS NULL AND #original_FirstName IS NULL)) AND (([LastName] = #original_LastName) OR ([LastName] IS NULL AND #original_LastName IS NULL)) AND (([Address] = #original_Address) OR ([Address] IS NULL AND #original_Address IS NULL))" InsertCommand="INSERT INTO [STUDENTS] ([Title], [FirstName], [LastName], [Address]) VALUES (#Title, #FirstName, #LastName, #Address)" OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [STUDENTS] WHERE ([StudentID] = #StudentID)" UpdateCommand="UPDATE [STUDENTS] SET [Title] = #Title, [FirstName] = #FirstName, [LastName] = #LastName, [Address] = #Address WHERE [StudentID] = #original_StudentID AND (([Title] = #original_Title) OR ([Title] IS NULL AND #original_Title IS NULL)) AND (([FirstName] = #original_FirstName) OR ([FirstName] IS NULL AND #original_FirstName IS NULL)) AND (([LastName] = #original_LastName) OR ([LastName] IS NULL AND #original_LastName IS NULL)) AND (([Address] = #original_Address) OR ([Address] IS NULL AND #original_Address IS NULL))">
<DeleteParameters>
<asp:Parameter Name="original_StudentID" Type="Int32" />
<asp:Parameter Name="original_Title" Type="String" />
<asp:Parameter Name="original_FirstName" Type="String" />
<asp:Parameter Name="original_LastName" Type="String" />
<asp:Parameter Name="original_Address" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="Address" Type="String" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="StudentID" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="original_StudentID" Type="Int32" />
<asp:Parameter Name="original_Title" Type="String" />
<asp:Parameter Name="original_FirstName" Type="String" />
<asp:Parameter Name="original_LastName" Type="String" />
<asp:Parameter Name="original_Address" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
<br />
</div>
</form>
</body>
</html>
This is your sql:
SELECT Courses.Courseid,
Grades.Grade,
Students.Studentid,
Students.Title,
Students.Firstname,
Students.Lastname
FROM Courses
INNER JOIN Grades
ON Courses.Courseid = Grades.Courseid
INNER JOIN Students
ON Grades.Studentid = Students.Studentid
WHERE ( Courses.Coursename = #CourseID )
Isn't it Courses.Courseid instead of Courses.Coursename? So:
WHERE ( Courses.Courseid = #CourseID )
( one of the reasons why i avoid declarative datasource controls )

DetailsView in Modalpopup won't load on second click on edit button

I have a GridView that when you click the edit button it loads a DetailsView in Edit Mode inside of a ModalPopup. It works fine the first time you click edit. If you click edit again to make changes to a second record, it loads but the DetailsView is not in the ModalPopup.
Can anyone tell me what I"m doing wrong? My code is below.
GridView datasource:
<asp:SqlDataSource ID="sdsMembers" runat="server"
ConnectionString="<%$ ConnectionStrings:DoseRec_ABTConnectionString %>"
SelectCommand="SELECT [intMemberID], [vcharTitle], [vcharFirstName], [vcharLastName], [vcharSuffix], [vcharJobTitle], [vcharAddress1], [vcharAddress2], [vcharCity], [vcharState], [vcharZipCode], [vcharPhone], [vcharFax], [bitActive] FROM [tbl_Members]"
DeleteCommand="DELETE FROM [tbl_Members] WHERE [intMemberID] = #intMemberID"
InsertCommand="INSERT INTO [tbl_Members] ([vcharTitle], [vcharFirstName], [vcharLastName], [vcharSuffix], [vcharJobTitle], [vcharAddress1], [vcharAddress2], [vcharCity], [vcharState], [vcharZipCode], [vcharPhone], [vcharFax], [bitActive]) VALUES (#vcharTitle, #vcharFirstName, #vcharLastName, #vcharSuffix, #vcharJobTitle, #vcharAddress1, #vcharAddress2, #vcharCity, #vcharState, #vcharZipCode, #vcharPhone, #vcharFax, #bitActive)"
UpdateCommand="UPDATE [tbl_Members] SET [vcharTitle] = #vcharTitle, [vcharFirstName] = #vcharFirstName, [vcharLastName] = #vcharLastName, [vcharSuffix] = #vcharSuffix, [vcharJobTitle] = #vcharJobTitle, [vcharAddress1] = #vcharAddress1, [vcharAddress2] = #vcharAddress2, [vcharCity] = #vcharCity, [vcharState] = #vcharState, [vcharZipCode] = #vcharZipCode, [vcharPhone] = #vcharPhone, [vcharFax] = #vcharFax, [bitActive] = #bitActive WHERE [intMemberID] = #intMemberID">
<DeleteParameters>
<asp:Parameter Name="intMemberID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="vcharTitle" Type="String" />
<asp:Parameter Name="vcharFirstName" Type="String" />
<asp:Parameter Name="vcharLastName" Type="String" />
<asp:Parameter Name="vcharSuffix" Type="String" />
<asp:Parameter Name="vcharJobTitle" Type="String" />
<asp:Parameter Name="vcharAddress1" Type="String" />
<asp:Parameter Name="vcharAddress2" Type="String" />
<asp:Parameter Name="vcharCity" Type="String" />
<asp:Parameter Name="vcharState" Type="String" />
<asp:Parameter Name="vcharZipCode" Type="String" />
<asp:Parameter Name="vcharPhone" Type="String" />
<asp:Parameter Name="vcharFax" Type="String" />
<asp:Parameter Name="bitActive" Type="Boolean" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="vcharTitle" Type="String" />
<asp:Parameter Name="vcharFirstName" Type="String" />
<asp:Parameter Name="vcharLastName" Type="String" />
<asp:Parameter Name="vcharSuffix" Type="String" />
<asp:Parameter Name="vcharJobTitle" Type="String" />
<asp:Parameter Name="vcharAddress1" Type="String" />
<asp:Parameter Name="vcharAddress2" Type="String" />
<asp:Parameter Name="vcharCity" Type="String" />
<asp:Parameter Name="vcharState" Type="String" />
<asp:Parameter Name="vcharZipCode" Type="String" />
<asp:Parameter Name="vcharPhone" Type="String" />
<asp:Parameter Name="vcharFax" Type="String" />
<asp:Parameter Name="bitActive" Type="Boolean" />
<asp:Parameter Name="intMemberID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
DetailsView datasource:
<asp:SqlDataSource ID="sdsMembersDetail" runat="server"
ConnectionString="<%$ ConnectionStrings:DoseRec_ABTConnectionString %>"
SelectCommand="SELECT [intMemberID] AS ID, [vcharTitle] AS Title, [vcharFirstName] AS 'First Name', [vcharLastName] AS 'Last Name', [vcharSuffix] AS Suffix, [vcharJobTitle] AS 'Job Title', [vcharAddress1] AS Address1, [vcharAddress2] AS Address2, [vcharCity] AS City, [vcharState] AS State, [vcharZipCode] AS 'Zip Code', [vcharPhone] AS Phone, [vcharFax] AS Fax, [bitActive] AS Active FROM [tbl_Members] WHERE ([intMemberID] = #intMemberID)">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="" Name="intMemberID"
QueryStringField="intMemberID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
GridView markup:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="gvMembers" runat="server" AutoGenerateColumns="False"
DataKeyNames="intMemberID" DataSourceID="sdsMembers" style="background-color:White;">
<Columns>
<asp:CommandField ShowDeleteButton="True" />
<asp:TemplateField ControlStyle-Width="50px" HeaderStyle-Width="60px">
<ItemTemplate>
<asp:LinkButton ID="btnViewDetails" runat="server" OnClick="BtnViewDetails_Click">Edit</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="intMemberID" HeaderText="ID"
InsertVisible="False" ReadOnly="True" SortExpression="intMemberID" />
<asp:BoundField DataField="vcharTitle" HeaderText="vcharTitle"
SortExpression="vcharTitle" />
<asp:BoundField DataField="vcharFirstName" HeaderText="First Name"
SortExpression="vcharFirstName" />
<asp:BoundField DataField="vcharLastName" HeaderText="Last Name"
SortExpression="vcharLastName" />
<asp:BoundField DataField="vcharSuffix" HeaderText="Suffix"
SortExpression="vcharSuffix" />
<asp:BoundField DataField="vcharJobTitle" HeaderText="Job Title"
SortExpression="vcharJobTitle" />
<asp:BoundField DataField="vcharAddress1" HeaderText="Address1"
SortExpression="vcharAddress1" />
<asp:BoundField DataField="vcharAddress2" HeaderText="Address2"
SortExpression="vcharAddress2" />
<asp:BoundField DataField="vcharCity" HeaderText="City"
SortExpression="vcharCity" />
<asp:BoundField DataField="vcharState" HeaderText="State"
SortExpression="vcharState" />
<asp:BoundField DataField="vcharZipCode" HeaderText="Zip Code"
SortExpression="vcharZipCode" />
<asp:BoundField DataField="vcharPhone" HeaderText="Phone"
SortExpression="vcharPhone" />
<asp:BoundField DataField="vcharFax" HeaderText="Fax"
SortExpression="vcharFax" />
<asp:CheckBoxField DataField="bitActive" HeaderText="Active"
SortExpression="bitActive" />
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
DetailsView marup:
<asp:Button id="btnShowPopup" runat="server" style="display:none" />
<ajaxToolKit:ModalPopupExtender
ID="mdlPopup" runat="server" TargetControlID="btnShowPopup" PopupControlID="pnlPopup"
CancelControlID="btnClose" BackgroundCssClass="modalBackground" />
<asp:Panel ID="pnlPopup" runat="server" Width="500px" style="display:none">
<asp:UpdatePanel ID="updPnlCustomerDetail" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lblMemberDetail" runat="server" Text="Member Detail" BackColor="lightblue" Width="95%" />
<asp:DetailsView ID="dvMemberDetail" runat="server" DefaultMode="Edit" Width="95%" BackColor="white" OnItemUpdating="dvMembersDetail_ItemUpdating">
</asp:DetailsView>
</ContentTemplate>
</asp:UpdatePanel>
<div align="right" style="width:95%">
<asp:LinkButton
ID="btnSave" runat="server" Text="Save"
Width="50px" onclick="btnSave_Click" />
<asp:LinkButton ID="btnClose" runat="server">Close</asp:LinkButton>
</div>
</asp:Panel>
Click event (to display the DetailsView):
protected void BtnViewDetails_Click(object sender, EventArgs e)
{
LinkButton btnDetails = sender as LinkButton;
GridViewRow row = (GridViewRow)btnDetails.NamingContainer;
this.sdsMembersDetail.SelectParameters.Clear();
this.sdsMembersDetail.SelectParameters.Add("intMemberID", Convert.ToString(this.gvMembers.DataKeys[row.RowIndex].Value));
this.dvMemberDetail.DataSource = this.sdsMembersDetail;
this.dvMemberDetail.DataBind();
this.updPnlCustomerDetail.Update();
this.mdlPopup.Show();
}
If any other code, like the code for my save button is needed just let me know and I will post it.
Here's my Save code:
protected void btnSave_Click(object sender, EventArgs e)
{
if (this.Page.IsValid)
{
this.dvMemberDetail.UpdateItem(true);
this.dvMemberDetail.ChangeMode(DetailsViewMode.ReadOnly);
this.dvMemberDetail.Visible = false;
this.mdlPopup.Hide();
this.gvMembers.DataBind();
this.UpdatePanel1.Update();
}
}
protected void dvMembersDetail_ItemUpdating(object sender, EventArgs e)
{
using (DoseRec_ABTEntities1 dbContext = new DoseRec_ABTEntities1())
{
TextBox id = (TextBox)dvMemberDetail.Rows[0].Cells[1].Controls[0];
int intID = Convert.ToInt32(id.Text);
tbl_Members mem = (from m in dbContext.tbl_Members
where m.intMemberID == intID
select m).Single();
TextBox title = (TextBox)dvMemberDetail.Rows[1].Cells[1].Controls[0];
TextBox firstname = (TextBox)dvMemberDetail.Rows[2].Cells[1].Controls[0];
TextBox lastname = (TextBox)dvMemberDetail.Rows[3].Cells[1].Controls[0];
TextBox suffix = (TextBox)dvMemberDetail.Rows[4].Cells[1].Controls[0];
TextBox jobtitle = (TextBox)dvMemberDetail.Rows[5].Cells[1].Controls[0];
TextBox address1 = (TextBox)dvMemberDetail.Rows[6].Cells[1].Controls[0];
TextBox address2 = (TextBox)dvMemberDetail.Rows[7].Cells[1].Controls[0];
TextBox city = (TextBox)dvMemberDetail.Rows[8].Cells[1].Controls[0];
TextBox state = (TextBox)dvMemberDetail.Rows[9].Cells[1].Controls[0];
TextBox zipcode = (TextBox)dvMemberDetail.Rows[10].Cells[1].Controls[0];
TextBox phone = (TextBox)dvMemberDetail.Rows[11].Cells[1].Controls[0];
TextBox fax = (TextBox)dvMemberDetail.Rows[12].Cells[1].Controls[0];
CheckBox active = (CheckBox)dvMemberDetail.Rows[13].Cells[1].Controls[0];
mem.vcharTitle = title.Text;
mem.vcharFirstName = firstname.Text;
mem.vcharLastName = lastname.Text;
mem.vcharSuffix = suffix.Text;
mem.vcharJobTitle = jobtitle.Text;
mem.vcharAddress1 = address1.Text;
mem.vcharAddress2 = address2.Text;
mem.vcharCity = city.Text;
mem.vcharState = state.Text;
mem.vcharZipCode = zipcode.Text;
mem.vcharPhone = phone.Text;
mem.vcharFax = fax.Text;
mem.bitActive = active.Checked;
dbContext.SaveChanges();
}
}

Can not update Column bound by an Image field in gridview asp.net

I have three columns in my Grid view named TweetText, TweetImageUrl and an Column of ImageFied
whose DataImageUrl Field is TweetImageURl. My problem is that When i use the Edit,update feature of grid, I cant edit/update the TweetImageUrl but I can Update TweetText. But when I remove The ImageField Column then I can update the TweetImageUrl Column too. So Can anyone help so that i can Update the TweetImageUrl with ImageField there in Grid Too?
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataKeyNames="TwitterUserId"
DataSourceID="SqlDataSource1" onrowcommand="GridView1_RowCommand"
PageSize="14" >
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="Approve" runat="server"
CommandName="Approve"
CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
Text="Approve" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="TweetText" HeaderText="TweetText"
SortExpression="TweetText" />
<asp:BoundField DataField="TweetImageUrl" HeaderText="TweetImageUrl"
SortExpression="TweetImageUrl" />
<asp:ImageField DataImageUrlField="TweetImageUrl" HeaderText="Images" ItemStyle-Height = "10px" ItemStyle-Width = "10px"
NullImageUrl="~/Admin/ajax-loader.gif">
</asp:ImageField>
</Columns>
<PagerSettings Mode="NextPreviousFirstLast" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:mistersmartyplantsConnectionString %>"
DeleteCommand="DELETE FROM [TwitterData] WHERE [TwitterUserId] = #original_TwitterUserId AND (([TweetId] = #original_TweetId) OR ([TweetId] IS NULL AND #original_TweetId IS NULL)) AND (([TwitterUserName] = #original_TwitterUserName) OR ([TwitterUserName] IS NULL AND #original_TwitterUserName IS NULL)) AND (([TweetText] = #original_TweetText) OR ([TweetText] IS NULL AND #original_TweetText IS NULL)) AND (([TweetImageUrl] = #original_TweetImageUrl) OR ([TweetImageUrl] IS NULL AND #original_TweetImageUrl IS NULL)) AND (([TwitterDate] = #original_TwitterDate) OR ([TwitterDate] IS NULL AND #original_TwitterDate IS NULL))"
InsertCommand="INSERT INTO [TwitterData] ([TweetId], [TwitterUserId], [TwitterUserName], [TweetText], [TweetImageUrl], [TwitterDate]) VALUES (#TweetId, #TwitterUserId, #TwitterUserName, #TweetText, #TweetImageUrl, #TwitterDate)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT [TweetId], [TwitterUserId], [TwitterUserName], [TweetText], [TweetImageUrl], [TwitterDate] FROM [TwitterData] WHERE ([Approved] = #Approved) ORDER BY [TwitterDate] DESC"
UpdateCommand="UPDATE [TwitterData] SET [TweetId] = #TweetId, [TwitterUserName] = #TwitterUserName, [TweetText] = #TweetText, [TweetImageUrl] = #TweetImageUrl, [TwitterDate] = #TwitterDate WHERE [TwitterUserId] = #original_TwitterUserId AND (([TweetId] = #original_TweetId) OR ([TweetId] IS NULL AND #original_TweetId IS NULL)) AND (([TwitterUserName] = #original_TwitterUserName) OR ([TwitterUserName] IS NULL AND #original_TwitterUserName IS NULL)) AND (([TweetText] = #original_TweetText) OR ([TweetText] IS NULL AND #original_TweetText IS NULL)) AND (([TweetImageUrl] = #original_TweetImageUrl) OR ([TweetImageUrl] IS NULL AND #original_TweetImageUrl IS NULL)) AND (([TwitterDate] = #original_TwitterDate) OR ([TwitterDate] IS NULL AND #original_TwitterDate IS NULL))">
<DeleteParameters>
<asp:Parameter Name="original_TwitterUserId" Type="String" />
<asp:Parameter Name="original_TweetId" Type="String" />
<asp:Parameter Name="original_TwitterUserName" Type="String" />
<asp:Parameter Name="original_TweetText" Type="String" />
<asp:Parameter Name="original_TweetImageUrl" Type="String" />
<asp:Parameter Name="original_TwitterDate" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="TweetId" Type="String" />
<asp:Parameter Name="TwitterUserId" Type="String" />
<asp:Parameter Name="TwitterUserName" Type="String" />
<asp:Parameter Name="TweetText" Type="String" />
<asp:Parameter Name="TweetImageUrl" Type="String" />
<asp:Parameter Name="TwitterDate" Type="String" />
</InsertParameters>
<SelectParameters>
<asp:Parameter DefaultValue="No" Name="Approved" Type="String" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="TweetId" Type="String" />
<asp:Parameter Name="TwitterUserName" Type="String" />
<asp:Parameter Name="TweetText" Type="String" />
<asp:Parameter Name="TweetImageUrl" Type="String" />
<asp:Parameter Name="TwitterDate" Type="String" />
<asp:Parameter Name="original_TwitterUserId" Type="String" />
<asp:Parameter Name="original_TweetId" Type="String" />
<asp:Parameter Name="original_TwitterUserName" Type="String" />
<asp:Parameter Name="original_TweetText" Type="String" />
<asp:Parameter Name="original_TweetImageUrl" Type="String" />
<asp:Parameter Name="original_TwitterDate" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
Use
<asp:TemplateField HeaderText="Images" ItemStyle-Height="10px" ItemStyle-Width="10px" >
<ItemTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval(TweetImageUrl) %>' Height="10px" Width="10px" />
</ItemTemplate>
</asp:TemplateField>
Rather then
<asp:ImageField DataImageUrlField="TweetImageUrl" HeaderText="Images" ItemStyle-Height = "10px" ItemStyle-Width = "10px" NullImageUrl="~/Admin/ajax-loader.gif"></asp:ImageField>
Hope It Helps. Good Luck.

passing dropdown value to update parameter for ASP.Net Gridview

I have a gridview that, when in edit mode, I use a dropdown to load all provinces, however, when I change the province and click update, my page crashes...I'm not sending the province parameter to the gridview's updateparameters properly...here's my code, someone please help..
<asp:GridView runat="server" ID="gvUsers" DataKeyNames="UserID" BackColor="#eeeeee" Width="85%"
HorizontalAlign="Center"
Font-Bold="False" Font-Names="Verdana"
Font-Size="10pt" AutoGenerateColumns="False"
OnRowDataBound="gvUsers_RowDataBound"
OnRowDeleting="gvUsers_RowDeleting" >
<HeaderStyle BackColor="#904601" ForeColor="White"
Font-Bold="True" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="Yellow" />
<AlternatingRowStyle BackColor="White" Font-Bold="false" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="LinkButton2"
CommandArgument='<%# Eval("UserID") %>'
CommandName="Select" runat="server">
Select</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="UserID" Visible="False" />
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("LastName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete?">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1"
CommandArgument='<%# Eval("UserID") %>'
CommandName="Delete" runat="server">
Delete</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle HorizontalAlign="Left" />
</asp:GridView><br /><br />
<asp:DetailsView runat="server" ID="dvUser" DataSourceID="SqlDataSource1" AutoGenerateRows="False" Width="85%" DataKeyNames="UserID"
HorizontalAlign="Center" AutoGenerateInsertButton="True" AutoGenerateEditButton="True" OnItemInserted="dvUsers_ItemInserted" >
<Fields>
<asp:BoundField DataField="UserID" Visible="False" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="UserName" HeaderText="UserName" ReadOnly="true" SortExpression="UserName" />
<asp:TemplateField HeaderText="Password">
<ItemTemplate>
<asp:Label runat="server" ID="lblPassword" Text="●●●●●●●●●"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtPassword" TextMode="Password" Text='<%# Bind("Password") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Birthdate" SortExpression="Birthdate">
<EditItemTemplate>
<asp:TextBox runat="server" ID="Birthdate" Text='<%# Bind("Birthdate") %>' ></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label runat="Server" ID="lblBirthdate" Text='<%# Bind("Birthdate") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
<asp:BoundField DataField="Apt" HeaderText="Apt" SortExpression="Apt" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:TemplateField HeaderText="Province">
<ItemTemplate>
<asp:Label runat="server" ID="lblProvince" Text='<%# Eval("ProvName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList runat="server" ID="ddlProvince" DataValueField="ProvinceID" DataSourceID="SqlDataSource2" DataTextField="Province"></asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="PostalCode" HeaderText="PostalCode" SortExpression="PostalCode" />
<asp:BoundField DataField="PhoneNum" HeaderText="PhoneNum" SortExpression="PhoneNum" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
<asp:CheckBoxField DataField="ynAdminUser" HeaderText="ynAdminUser" SortExpression="ynAdminUser" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource2"
runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT ProvinceID, Province FROM tblProvince"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource1"
runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT a.UserID, a.FirstName, a.LastName, a.UserName, a.Password, a.Birthdate, a.Address, a.Apt, a.City, a.Province, b.Province as 'ProvName',
a.PostalCode, a.PhoneNum, a.Email, a.ynAdminUser
FROM tblUser a
INNER JOIN tblProvince B ON A.Province = B.ProvinceID
WHERE (a.UserID = #UserID) AND (a.ynDelete = 0)"
InsertCommand="INSERT INTO tblUser(FirstName, LastName, UserName, Password, Birthdate, Address, Apt, City, Province, PostalCode, Email, PhoneNum, ynAdminUser, ynDelete) VALUES (#FirstName, #LastName, #UserName, #Password, #Birthdate, #Address, #Apt, #City, #Province, #PostalCode, #Email, #PhoneNum, #ynAdminUser, 0)"
UpdateCommand="UPDATE tblUser SET FirstName = #FirstName, LastName = #LastName, Birthdate = #Birthdate, Address = #Address, Apt = #Apt, City = #City, Province = #Province, PostalCode = #PostalCode, PhoneNum = #PhoneNum, Email = #Email, ynAdminUser = #ynAdminUser WHERE (UserID = #UserID)">
<SelectParameters>
<asp:ControlParameter ControlID="gvUsers" Name="UserID" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter DbType="DateTime" Name="BirthDate" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="Apt" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:ControlParameter Name="Province" ControlID="ddlProvince" PropertyName="SelectedValue" Type="Int32" />
<asp:Parameter Name="PhoneNum" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="ynAdminUser" Type="Boolean" />
<asp:Parameter Name="UserID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="UserName" Type="String" />
<asp:Parameter Name="Password" Type="String" />
<asp:Parameter DbType="DateTime" Name="Birthdate" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="Apt" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="Province" Type="Int32" />
<asp:Parameter Name="PostalCode" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="PhoneNum" Type="String" />
<asp:Parameter Name="ynAdminUser" Type="Boolean" />
</InsertParameters>
</asp:SqlDataSource>
You don't need the control binding:
<asp:ControlParameter Name="Province" ControlID="ddlProvince" PropertyName="SelectedValue" Type="Int32" />
Instead, use a regualar parameter like your others and add the following binding to your drop-down list for the edit mode of the gridview:
SelectedValue=<%#Bind("Province")%>
I realize this is a really old question, and I hope you found your answer.
Looking at your markup, though, I want to say your connection strings were never filled out:
runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
I am not the strongest when it comes to ASP.NET databinding in the markup code, but I am pretty sure your connection string needs to point to an actual string name in your web.Config file's ConnectionStrings section:
<connectionStrings>
<clear />
<add name="Mark1" connectionString="Data Source=localhost;Initial Catalog=Table1;Integrated Security=True;" providerName="System.Data.SqlClient" />
</connectionStrings>
Use whatever your actual connection string is, though.
Now, your markup should be written as:
runat="server" ConnectionString="<%$ ConnectionStrings:Mark1 %>"
Again, I'm new to this. I found this only while trying to search for ways to solve my own problems.
If this is wrong (possible), someone just let me know what I did wrong and I'll delete it.

Resources