[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

Gridview disappears when I click Edit

Asked by bhorlings in Programming for ASP.NET

Tags: gridview, edit, disappears, click

I am creating a page to add maintenance technicians to a sql express table. I want to be able to edit a gridview. I have added it and associated my stored procedures with the datasource. The problem is that when I click edit the gridview disappears. Below is my code for the page and the stored procedure.

ASPX Page
#####################################

<%@ Page Language="VB" MasterPageFile="~/masters/leftnavbar_maint_tasks.master" AutoEventWireup="false" CodeFile="technicians.aspx.vb" Inherits="maint_technicians" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphMain" Runat="Server">
<h4>Add Technicians...</h4>
    <asp:formview datakeynames="id" datasourceid="srcTechs" defaultmode="Insert" id="frmAddTechs" runat="server">
        <insertitemtemplate>
            First Name:
            <asp:textbox id="txtfirst_name" runat="server" text='<%# Bind("first_name") %>'></asp:textbox><br />
            Last Name:
            <asp:textbox id="txtLastName" runat="server" text='<%# Bind("last_name") %>'></asp:textbox><br />
            <asp:linkbutton id="InsertButton" runat="server" causesvalidation="True" commandname="Insert"
                text="Insert"></asp:linkbutton>
            <asp:linkbutton id="InsertCancelButton" runat="server" causesvalidation="False" commandname="Cancel"
                text="Cancel"></asp:linkbutton>
        </insertitemtemplate>
    </asp:formview>
    <asp:sqldatasource id="srcTechs" runat="server" connectionstring="<%$ ConnectionStrings:conMaintTasks %>"
        insertcommand="sp_insert_tech" insertcommandtype="StoredProcedure" selectcommand="sp_select_tech" selectcommandtype="StoredProcedure" updatecommand="sp_update_tech" updatecommandtype="StoredProcedure">
        <insertparameters>
            <asp:parameter name="first_name" type="String" />
            <asp:parameter name="last_name" type="String" />
        </insertparameters>
        <updateparameters>
            <asp:parameter name="first_name" type="String" />
            <asp:parameter name="last_name" type="String" />
            <asp:parameter name="email" type="String" />
            <asp:parameter name="active" type="Boolean" />
            <asp:parameter name="original_id" type="Int32" />
            <asp:parameter name="original_first_name" type="String" />
            <asp:parameter name="original_last_name" type="String" />
            <asp:parameter name="original_email" type="String" />
            <asp:parameter name="original_active" type="Boolean" />
        </updateparameters>
        <deleteparameters>
            <asp:parameter name="original_id" type="Int32" />
            <asp:parameter name="original_first_name" type="String" />
            <asp:parameter name="original_last_name" type="String" />
            <asp:parameter name="original_email" type="String" />
            <asp:parameter name="original_active" type="Boolean" />
        </deleteparameters>
    </asp:sqldatasource>
<h4>Current Technicians...</h4>
<asp:gridview id="grdTechs" runat="server" e autogeneratecolumns="False" datakeynames="id"
        datasourceid="SqlDataSource1" allowsorting="True">
        <columns>
            <asp:commandfield showeditbutton="True" />
            <asp:boundfield datafield="id" headertext="id" insertvisible="False" readonly="True"
                sortexpression="id" visible="False" />
            <asp:boundfield datafield="first_name" headertext="First Name" sortexpression="first_name" />
            <asp:boundfield datafield="last_name" headertext="Last Name" sortexpression="last_name" />
            <asp:boundfield datafield="email" headertext="Email Address" sortexpression="email" />
            <asp:checkboxfield datafield="active" headertext="Active" sortexpression="active" />
        </columns>
    <rowstyle font-size="Small" />
    <headerstyle font-bold="True" />
    </asp:gridview>
    <asp:sqldatasource id="SqlDataSource1" runat="server" conflictdetection="CompareAllValues"
        connectionstring="<%$ ConnectionStrings:conMaintTasks %>" deletecommand="DELETE FROM [tech] WHERE [id] = @original_id AND [first_name] = @original_first_name AND [last_name] = @original_last_name AND [email] = @original_email AND [active] = @original_active"
        insertcommand="INSERT INTO [tech] ([first_name], [last_name], [email], [active]) VALUES (@first_name, @last_name, @email, @active)"
        oldvaluesparameterformatstring="original_{0}" selectcommand="SELECT * FROM [tech]"
        updatecommand="UPDATE [tech] SET [first_name] = @first_name, [last_name] = @last_name, [email] = @email, [active] = @active WHERE [id] = @original_id AND [first_name] = @original_first_name AND [last_name] = @original_last_name AND [email] = @original_email AND [active] = @original_active">
        <deleteparameters>
            <asp:parameter name="original_id" type="Int32" />
            <asp:parameter name="original_first_name" type="String" />
            <asp:parameter name="original_last_name" type="String" />
            <asp:parameter name="original_email" type="String" />
            <asp:parameter name="original_active" type="Boolean" />
        </deleteparameters>
        <updateparameters>
            <asp:parameter name="first_name" type="String" />
            <asp:parameter name="last_name" type="String" />
            <asp:parameter name="email" type="String" />
            <asp:parameter name="active" type="Boolean" />
            <asp:parameter name="original_id" type="Int32" />
            <asp:parameter name="original_first_name" type="String" />
            <asp:parameter name="original_last_name" type="String" />
            <asp:parameter name="original_email" type="String" />
            <asp:parameter name="original_active" type="Boolean" />
        </updateparameters>
        <insertparameters>
            <asp:parameter name="first_name" type="String" />
            <asp:parameter name="last_name" type="String" />
            <asp:parameter name="email" type="String" />
            <asp:parameter name="active" type="Boolean" />
        </insertparameters>
    </asp:sqldatasource>
   
</asp:Content>

ASPX.VB File
#####################################
Partial Class maint_technicians
    Inherits System.Web.UI.Page

End Class

Stored Procedure
###############################
ALTER PROCEDURE dbo.sp_update_tech
(
      @first_name varchar(50),
      @last_name varchar(50),
      @email varchar(50),
      @active bit,
      @Original_id int,
      @IsNull_first_name Int,
      @Original_first_name varchar(50),
      @IsNull_last_name Int,
      @Original_last_name varchar(50),
      @IsNull_email Int,
      @Original_email varchar(50),
      @IsNull_active Int,
      @Original_active bit,
      @id int
)
AS
      SET NOCOUNT OFF;
UPDATE [tech] SET [first_name] = @first_name, [last_name] = @last_name, [email] = @email, [active] = @active WHERE (([id] = @Original_id) AND ((@IsNull_first_name = 1 AND [first_name] IS NULL) OR ([first_name] = @Original_first_name)) AND ((@IsNull_last_name = 1 AND [last_name] IS NULL) OR ([last_name] = @Original_last_name)) AND ((@IsNull_email = 1 AND [email] IS NULL) OR ([email] = @Original_email)) AND ((@IsNull_active = 1 AND [active] IS NULL) OR ([active] = @Original_active)));
      
SELECT id, first_name, last_name, email, active FROM tech WHERE (id = @id)
 
Related Solutions
Keywords: Gridview disappears when I click Edit
 
Loading Advertisement...
 
[+][-]10/23/07 10:11 PM, ID: 20136445Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/24/07 05:06 AM, ID: 20137993Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/24/07 09:52 AM, ID: 20140653Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/24/07 09:55 AM, ID: 20140691Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/25/07 04:43 AM, ID: 20146643Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Programming for ASP.NET
Tags: gridview, edit, disappears, click
Sign Up Now!
Solution Provided By: noulouk
Participating Experts: 1
Solution Grade: B
 
[+][-]10/26/07 01:06 PM, ID: 20158631Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 / EE_QW_1_20070628