SqlDataSource && DetailsView UpdateCommand

Mar 6, 2006

Hi

I have a Page with a DetailsView and SqlDataSource. When Editing the DetailsView the Sql;DataSource UpdateCommand does not seem to pick up the @parameters of the form fields. I have used OnItemUpdating to view all Keys/OldValues/NewValues passed into the UpdateCommand but nothing seems to be picked up.

When I place a value into UpdateCommand it updates correctly but does not when I use the form. At this stage I have simplified the code down to typical Master-Details Pages (Separate) using a QueryString to filter the SelectCommand. But nothing seems to work.

Please help! I have wasted so much time trying to resolve this and I am on deadline and need this to work.

Thanks

Dave

View 3 Replies


ADVERTISEMENT

UpdateCommand For SQLDataSource

Apr 13, 2007

I have a custom setup so bear with me here in my explanation.  The SelectCommand for my SQLDataSource gets data from a table using a QueryString for filtering by the record ID. A Repeater control is then used to populate the data into different Textboxes on the page (and a custom HTML-editor control). This works 100%.  I'm trying to use the UpdateCommand for the SQLDataSource to then update the record with the data that the user changes. (Example: FieldA is "foo" and the user changes it to "foobar". When the form is submitted, it then updates FieldB to be "foobar").  The form is being submitted, but the data isn't being updated at all.  Any ideas? Thanks for the help in advance. 

View 11 Replies View Related

Sqldatasource.updatecommand

May 11, 2006

I have a SQLDataSource that has an UpdateCommand assigned to it.  At certain times I may need to change the UpdateCommand to save different info to the database.  I thought I would be able to use sqldatasource.updatecommand.equals() to change the UpdateCommand and then call the sqldatasource.update method, but it didn't work...the default command was still used.  Is there something else I need to change?  I figured my next option would be to create another sqldatasource.  Any help would be great!

View 4 Replies View Related

UpdateCommand In Sqldatasource Control

Oct 15, 2007

Hello all,
I am trying to update the record which involed the modification of key in Datakeynames, but when i click the update button from gridview, it doesn't allow to change the value of modified column.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" DataSourceMode="DataSet"                 ConnectionString="<%$ ConnectionStrings:WebsiteDataConnection %>" OldValuesParameterFormatString="old_{0}"                SelectCommand="SELECT * FROM [ServiceAgents]"                InsertCommand="INSERT INTO ServiceAgents VALUES(@Ser_STATE, @Ser_CITY, @Ser_AGENT, @Ser_PHONE, @Ser_EQUIPMENT)"                UpdateCommand="UPDATE ServiceAgents SET AGENT=@AGENT, PHONE=@PHONE WHERE (STATE=@STATE and CITY=@CITY and AGENT=@old_AGENT and EQUIPMENT=@EQUIPMENT)"                DeleteCommand="DELETE FROM ServiceAgents WHERE (STATE=@STATE and CITY=@CITY and AGENT=@AGENT and EQUIPMENT=@EQUIPMENT)" >                                <UpdateParameters>                    <asp:Parameter Type="String" Name="AGENT" />                    <asp:Parameter Type="String" Name="PHONE" />                                         <asp:Parameter Name="old_AGENT" />                    <asp:Parameter Type="String" Name="STATE" />                    <asp:Parameter Type="String" Name="CITY" />                    <asp:Parameter Type="String" Name="EQUIPMENT" />                </UpdateParameters>                                <InsertParameters>                    <asp:ControlParameter Name="Ser_STATE" ControlID="TextBox_state"/>                    <asp:ControlParameter Name="Ser_CITY" ControlID="TextBox_city"/>                    <asp:ControlParameter Name="Ser_AGENT" ControlID="TextBox_agent"/>                    <asp:ControlParameter Name="Ser_PHONE" ControlID="TextBox_phone"/>                    <asp:ControlParameter Name="Ser_EQUIPMENT" ControlID="TextBox_equip" />                   </InsertParameters>                                <DeleteParameters>                   <asp:Parameter Type="String" Name="STATE" />                    <asp:Parameter Type="String" Name="CITY" />                    <asp:Parameter Type="String" Name="AGENT" />                    <asp:Parameter Type="String" Name="EQUIPMENT" />                </DeleteParameters>                            </asp:SqlDataSource>
Does anyone got any ideas about it? Where is wrong in the control?

View 3 Replies View Related

SqlDataSource UpdateCommand Plus Insert

Oct 22, 2007

SqlDataSource UpdateCommand plus Insert
I have a SqlDataSource with an UpdateCommand but besides that i need also an Insert command triggered on the same update command.
That´s because i need to update a record and at the same time include a log of that update in another database.
Thanks

View 3 Replies View Related

SQLDataSource: Update 2 Tables With 1 UpdateCommand?

Mar 16, 2007

I have a Gridview (edit enabled), connected to a SQLDataSource.
 SQLDataSource populates the gridview from 1 SelectCommand.
 figure1:
ColumnA | ColumnB | ColumnC
 
I have 2 SQL Server 2005 tables: Table1 and Table2 
Now on my SQLDataSource's UpdateCommand, I want the value of ColumnB to go to Table1's ColumnB, and ColumnC to go to Table2's ColumnC.
How do I do this?
I understand I can't do this with 1 UPDATE-SET sql query. Maybe I can with stored procs or something, but im kinda noobish when it comes to this. How? Thanks

View 1 Replies View Related

How To Programmatically Construct The UpdateCommand For SqlDataSource

Aug 1, 2007

Hi, All
I'm using Gridview and SqlDataSource to dynamically display the contents in different tables, as followed:
<%   dataSource.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["connectionString"];   dataSource.SelectCommand = "SELECT * FROM " + tableName;   gridView.DataBind();
   dataSource.UpdateCommand = "";%>
<asp:SqlDataSource ID="dataSource" runat="server"></asp:SqlDataSource><asp:GridView ID="gridView" runat="server" DataSourceID="dataSource" AllowPaging="True" AllowSorting="True" AutoGenerateEditButton="True" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" PageSize="20" DataKeyNames="ID" OnRowDataBound="tableGridView_RowDataBound">    <HeaderStyle BackColor="#C0C0FF" />    <AlternatingRowStyle BackColor="#C0FFC0" /></asp:GridView>
The datasource take the "tableName" as argument to determine which table to display. My problem is I can't figure out a way to programmatically construct the UpdataCommand for the SqlDataSource. I try to get the field names from the HeaderRow, but all the cells are empty in this row.
Does anyone know what causes the problem or how to construct the UpdateCommand properly. Thanks!

View 3 Replies View Related

GridView Update, With SqlDataSource UpdateCommand Set From Code-behind. (C#)

Mar 9, 2006

Hi all
I have a GridView on an aspx page, that is enabled for editing, deletion and sorting.
In the Page_Load event of the aspx page, i add a SqlDataSource to the page, and bind the source to the GridView.
When i click the update, or delete button, it makes a PostBack, but nothing is affected. I'm sure this has got something to do with the parameters.
First, i tried having the GridView.AutoGenerateColumns set to True. I have also tried adding the columns manually, but no affect here either.
The code for setting the commands, and adding the SqlDataSource to the page are as follows:
            string strConn = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;            string strProvider = ConfigurationManager.ConnectionStrings["ConnectionString"].ProviderName;            string selectCommand = "SELECT * FROM rammekategori";                        SqlDataSource ds = new SqlDataSource(strProvider, strConn, selectCommand);            ds.ID = "RammeKategoriDS";            ds.UpdateCommand = "UPDATE rammekategori SET Kategoribeskrivelse = @Kategoribeskrivelse WHERE (Kategorinavn = @Kategorinavn)";            ds.DeleteCommand = "DELETE FROM rammekategori WHERE (Kategorinavn = @Kategorinavn)";                        Parameter Kategorinavn = new Parameter("Kategorinavn", TypeCode.String);            Parameter Kategoribeskrivelse = new Parameter("Kategoribeskrivelse", TypeCode.String);            ds.UpdateParameters.Add(Kategorinavn);            ds.UpdateParameters.Add(Kategoribeskrivelse);            ds.DeleteParameters.Add(Kategorinavn);
            Page.Controls.Add(ds);
            SqlDataSource m_SqlDataSource = Page.FindControl("RammeKategoriDS") as SqlDataSource;
            if (m_SqlDataSource != null)            {                this.gvRammeKategorier.DataSourceID = m_SqlDataSource.ID;            }
As mentioned - no affect at all!
Thanks in advance - MartinHN
 

View 4 Replies View Related

Can't Update A Record Using A DetailsView And SqlDataSource

Feb 13, 2007

Hi,I'm trying to create a registration page that I've divided into multiple pages (first page for basic details, next page for address, etc.). I insert the record in the first page, and update it in the other pages. I pass the newly created ID to the other pages using the Page.PreviousPage property.  In the second page, I have the SqlDataSource configured as "SELECT * FROM [Table] WHERE ID = ?", and the UpdateCommand is "UPDATE .... WHERE ID = ?".  In Page_Load, I am updating the SelectCommand to "SELECT ... WHERE ID = " & intID, and the UpdateCommand similarly. The I do a dtlsvw.Databind()But when I go to the next page (the newly created ID is being passed properly), the update doesn't do anything. The new record doesn't contain the values in the detailsview. Can somebody help me out? Thanks,Wild Thing 

View 2 Replies View Related

SQLDataSource, Stored Procedure, DetailsView

Jul 30, 2007

For some reason I can't make the stars align.  Could someone spot the problem here?  I'm looking to select the Identity of my last inserted record in the code behind my DetailsView.  Here are the relavent bits:
Stored Procedure:ALTER PROCEDURE usp_EW_INSERTMajor
@StartDate datetime, @Finishdate datetime, @ProjectName nvarchar(1000), @WorkCell nvarchar(1000),
@JobName nvarchar(1000), @PartName nvarchar(1000), @StatusID int, @ResponsibleID int, @FacilityID int

AS
Set nocount on

DECLARE @ProjectID int
/*This saves the bits to the Project table*/
INSERT INTO EW_Project (ProjectTypeID,FacilityID,StartDate,FinishDate,Status,EmployeeID)
VALUES(1,@FacilityID,@StartDate,@FinishDate,@StatusID,@ResponsibleID)


/*This saves the bits to the Major table*/



SET @ProjectID = SCOPE_IDENTITY()
INSERT INTO EW_MajorBasic(ProjectID,ProjectName,WorkCell,JobName,PartName)
VALUES (@ProjectID,@Projectname,@WorkCell,@JobName,@PartName)

Set nocount off

SELECT @ProjectID as ProjectID
 
SQLDataSource<asp:SqlDataSource ID="ProjectData" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
SelectCommand="usp_EW_GETMajorBasic"
SelectCommandType="StoredProcedure"
UpdateCommand="usp_EW_UPDATEMajorBasic"
InsertCommand="usp_EW_INSERTMajor"
InsertCommandType="StoredProcedure"
UpdateCommandType="StoredProcedure"
DeleteCommand="DELETE FROM EW_Project WHERE ProjectID = @ProjectID"
>
<UpdateParameters>
<asp:Parameter Name="ProjectID" Type="Int32" />
<asp:Parameter Name="StartDate" Type="DateTime" />
<asp:Parameter Name="Finishdate" Type="DateTime" />
<asp:Parameter Name="ProjectName" Type="String" />
<asp:Parameter Name="WorkCell" Type="String" />
<asp:Parameter Name="JobName" Type="String" />
<asp:Parameter Name="PartName" Type="String" />
<asp:Parameter Name="StatusID" Type="Int32" />
<asp:Parameter Name="ResponsibleID" Type="Int32" />
<asp:CookieParameter CookieName="EW_FacilityID" Name="FacilityID" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="StartDate" Type="DateTime" />
<asp:Parameter Name="Finishdate" Type="DateTime" />
<asp:Parameter Name="ProjectName" Type="String" />
<asp:Parameter Name="WorkCell" Type="String" />
<asp:Parameter Name="JobName" Type="String" />
<asp:Parameter Name="PartName" Type="String" />
<asp:Parameter Name="StatusID" Type="Int32" />
<asp:Parameter Name="ResponsibleID" Type="Int32" />
<asp:CookieParameter CookieName="EW_FacilityID" Name="FacilityID" />
</InsertParameters>
<SelectParameters>
<asp:Parameter Name="ProjectID" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="ProjectID" />
</DeleteParameters>
</asp:SqlDataSource>
 
DetailsView<asp:DetailsView
ID="DetailsView1"
runat="server"
AutoGenerateRows="False"
DataKeyNames="ProjectID"
DataSourceID="ProjectData"
SkinID="SimpleDetailsView"
OnItemDeleted="ProjectData_Deleted"
OnItemInserted="DetailsView1_ItemInserted">  
 
Code-Behind: Sub DetailsView1_ItemInserted(ByVal sender As Object, ByVal e As DetailsViewInsertedEventArgs) Handles DetailsView1.ItemInserted
Dim newID As Integer = e.Values("ProjectID")
testlabel.Text = newID
End Sub
 
 
To be clear, everything is working.  When I come to this page with an ID, the records display fine (Select works).  The Update and Delete work just fine.  The Insert works fine too.  It's just that the ItemInserted part does not want to grab the ProjectID.  Specifically, testlabel displays a Zero. 

View 2 Replies View Related

DeleteCommand And UpdateCommand

Aug 1, 2006

I have added a gridview and under its properties i have changed AutoGenerateDeleteButton and AutoGenerateEditButton to true.
The problem is... when I try and delete a record, I get this error: Deleting is not supported by data source 'SqlDataSource1' unless DeleteCommand is specified
If I try and update.. i get the error: Updating is not supported by data source 'SqlDataSource1' unless UpdateCommand is specified.
Can someone please help me out... maybe with some code... or a link to a tutorial..
Thanks
Canning

View 18 Replies View Related

Have A Problem With UpdateCommand

Dec 28, 2006

Hello everyone,
 I am a bit new to ASP .Net so forgive me, if I dont understand something right off.
I am writing a page that gets code from the SQL database and puts it into a GridView. To get the information I am using SqlDataSource. I cant post an error message because I am running this off remote server but though testing I figure that it crashes when I add
Analysis = @Analysis
line into the UpdateCommand. First I thought that maybe my parameters were not read correcty but when I tried something like
Analysis  = 6
it worked. Then I tried to replace CQNo=@CQNo with
CQNo = @Analysis
and it also worked.
 I am very much puzzed at this. In SQL database CQNo is varchar, WorkDate is DateTime and Analysis is Money type.
 Can someone please help, I am out of ideas. Thanks!
<asp:SqlDataSource ID="myEfforts" runat="server"
SelectCommand="SELECT SNo, CQNo, WorkDate, Analysis, Design, Coding, Testing, DesRev, CodeRev, PeerRev, SysTest, PostInstall, Others, TotEff FROM Effort WHERE EmpId = @EmpId ORDER BY WorkDate DESC"
DeleteCommand="DELETE FROM Effort WHERE SNo=@SNo"
UpdateCommand="UPDATE Effort SET CQNo = @CQNo, WorkDate=@WorkDate Analysis=@Analysis WHERE SNo=@SNo">
<SelectParameters>
<asp:SessionParameter DefaultValue="" Name="EmpId" SessionField="PR_EmpIDVal" Type="String" />
</SelectParameters>

View 6 Replies View Related

Updatecommand Not Working With SqlDataAdapter

Aug 14, 2007

I know there are loads of posts on this, but this just will not update. I have tried various forms of the code all to no avail.  And now I'm ready to throw my PC out the window........
 What am I doing wrong? 
cheers Mike
Dim da As SqlDataAdapterDim dSetOrp As DataSet
oCn = New SqlConnection(db.m_ConnectionString)
oCn.Open()da = New SqlDataAdapter("Select * from contact WHERE conid = " & lngConId, oCn)
dSetOrp = New DataSet
da.Fill(dSetOrp, "locTable")  ' Fill the DataSet.
dSetOrp.Tables(0).Rows(0)("ConSttDate") = dtEffDateDim myBuilder As SqlCommandBuilder = New SqlCommandBuilder(da)
myBuilder.GetUpdateCommand()
da.UpdateCommand = myBuilder.GetUpdateCommand()
 lRows = da.Update(dSetOrp, "locTable")

View 2 Replies View Related

Update Detailsview

Dec 18, 2007

Hi,I am using detailsview to update my database and got a question regarding datetime format. Here is part of my code:
<asp:TemplateField HeaderText="Project Deadline">
<EditItemTemplate>
<asp:TextBox ID="txtDeadline_edit" runat="server" Text='<%# Bind("pro_app_deadline") %>'></asp:TextBox>
<asp:CompareValidator ID="txtDeadlineedit_validator" runat="server" ErrorMessage="Not a valid date format" ControlToValidate="txtDeadline_edit" Operator="DataTypeCheck" Type="Date"></asp:CompareValidator>
</EditItemTemplate>
<ItemTemplate><asp:Label ID="txtDeadline" runat="server" Text='<%# Eval("pro_app_deadline") %>'></asp:Label>
</ItemTemplate></asp:TemplateField>
 Since the format of my parameter 'pro_app_deadline' is datetime, it get stored as YYYY-MM-DD hh:mm:ss in datebase. If I want to validate user's input like above way, it always fails since hh:mm:ss append to YYYY-MM-DD. My question is, is there some way I can avoid hh:mm:ss?
Thanks a lot!

View 2 Replies View Related

DetailsView Control (Please Help!!!!)

May 14, 2006

Can someone please tell me what I am doing wrong...
I have a simple webform that has contains a GridView and a DetailsView. Once the GridView is populated the user simply selects a record from the list.  The DetailsView is them populated with all of the data from the selected record.
The DetailsView is bound to a SQL DataSource/CustomerData. I have made sure that the DV control has the Edit/Update Command listed.  The user can click the Edit button and successfully edit the fields but when the user clicks the "Update" button I am getting the following message.
Updating is not supported by data source 'CustomerData' unless UpdateCommand is specified
Why isnt the control handling the Update.
Many Thanks!!!!
T
 
 

View 4 Replies View Related

How To Update Multiple Tables With Updatecommand

Jun 5, 2007

 hi all,i'm working on a formview which will update 2 tables which are linked together but..i'm getting an error of the control not being found.my code is as shown below                           <asp:SqlDataSource ID="invDetSrc" runat="server"                                                ConnectionString="<%$ ConnectionStrings:rockwellConnectionString %>"                                               ProviderName="<%$ ConnectionStrings:rockwellConnectionString.ProviderName %>"                                               SelectCommand="SELECT rockwell.logix_asset_list.Inventory_ID, rockwell.vendor.Vendor_Name, rockwell.logix_asset_list_category.Category_Name, rockwell.logix_asset_list.Total_Quantity, rockwell.logix_asset_list.Quantity_In_Stock, rockwell.logix_asset_list.Part_Number, rockwell.logix_asset_list.On_Order, rockwell.logix_asset_list.ImageUrl, rockwell.logix_asset_list.DrawingUrl, rockwell.logix_asset_list.Description FROM rockwell.logix_asset_list, rockwell.logix_asset_list_category, rockwell.vendor WHERE rockwell.logix_asset_list.Logix_Asset_List_Category_ID = rockwell.logix_asset_list_category.Logix_Asset_List_Category_ID AND rockwell.logix_asset_list.Vendor_ID = rockwell.vendor.Vendor_ID AND&#13;&#10;rockwell.logix_asset_list.Part_Number = ?"                                               UpdateCommand="UPDATE vendor, logix_asset_list                                                set                                                vendor.vendor_name= @Vendor_Name,                                                logix_asset_list.Total_Quantity=@Total_Quantity,                                               logix_asset_list.Quantity_In_Stock=@Quantity_In_Stock,                                               logix_asset_list.Part_Number=@Part_Number,                                               logix_asset_list.On_Order=@On_Order,                                               logix_asset_list.Description=@Description                                               WHERE                                               logix_asset_list.Vendor_ID = vendor.Vendor_ID                                               and logix_asset_list.Inventory_ID = @Inventory_ID" >                               <SelectParameters>                                   <asp:ControlParameter ControlID="rstGrid" Name="?" PropertyName="SelectedValue" />                               </SelectParameters>                               <UpdateParameters>                               <asp:ControlParameter Type="Int32" ControlID="Total_Quantity" ConvertEmptyStringToNull="true" Name="@Total_Quantity"/>                               <asp:ControlParameter Type="string" ControlID="Vendor_Name" ConvertEmptyStringToNull="true" Name="@Vendor_Name"/>                               <asp:ControlParameter Type="Int32" ControlID="Quantity_In_Stock" ConvertEmptyStringToNull="true" Name="@Quantity_In_Stock"/>                               <asp:ControlParameter Type="string" ControlID="Part_Number" ConvertEmptyStringToNull="true" Name="@Part_Number"/>                               <asp:ControlParameter Type="string" ControlID="On_Order" ConvertEmptyStringToNull="true" Name="@On_Order"/>                               <asp:ControlParameter Type="string" ControlID="Description" ConvertEmptyStringToNull="true" Name="@Description"/>                               <asp:ControlParameter Type="Int32" ControlID="Inventory_ID" ConvertEmptyStringToNull="true" Name="@Inventory_ID"/>                               </UpdateParameters>                            </asp:SqlDataSource> <asp:FormView ID="FormView1" runat="server" BackColor="White" BorderColor="#DEDFDE"                                BorderStyle="None" BorderWidth="1px" CellPadding="4" DataSourceID="invDetSrc"                                ForeColor="Black" GridLines="Vertical" DataKeyNames="Inventory_ID"> <EditItemTemplate>                                    <table border="0" cellpadding="3" cellspacing="3" style="background-color: white; color: black;">                                        <tr>                                            <td colspan="2">                                                <asp:Image ID="Image1" runat="server" Height="150px" ImageUrl='<%# "~/Image/photo/Logix%20Asset/"+Eval("Category_Name")+"/"+Eval("ImageUrl") %>'                                                    Width="150px" />                                                <br />                                                <asp:HyperLink ID="drawingLink" runat="server" NavigateUrl='<%# "~/Image/drawing/Logix%20Asset/"+Eval("Category_Name")+"/"+Eval("DrawingUrl") %>'                                                    Target="_blank" Text="View Drawing" ForeColor="Blue"></asp:HyperLink>                                            </td>                                            <asp:HiddenField ID="HiddenField1" runat="server" Value='<%# Bind("Inventory_ID") %>' />                                        </tr>                                        <tr>                                            <td style="color: black">                                                Part Number:</td>                                            <td>                                                <asp:TextBox ID="Part_Number" runat="server" Text='<%# Bind("Part_Number")%>'></asp:TextBox>                                                </td>                                        </tr>                                        <tr>                                            <td>                                                <strong style="color: black">Vendor:</strong></td>                                            <td>                                                <asp:TextBox ID="Vendor_Name" runat="server" Text='<%# Bind("Vendor_Name")%>'></asp:TextBox>                                                </td>                                        </tr>                                        <tr>                                            <td style="color: black">                                                <strong>Total Quantity:</strong></td>                                            <td>                                                <asp:TextBox ID="Total_Quantity" runat="server" Text='<%# Bind("Total_Quantity")%>'></asp:TextBox>                                                </td>                                        </tr>                                        <tr>                                            <td style="color: black">                                                <strong>Quantity In Stock:</strong></td>                                            <td>                                                <asp:TextBox ID="Quantity_In_Stock" runat="server" Text='<%# Bind("Quantity_In_Stock")%>'></asp:TextBox>                                         </td>                                        </tr>                                        <tr>                                            <td style="color: black">                                                <strong>Quantity on Order:</strong></td>                                            <td>                                                <asp:TextBox ID="On_Order" runat="server" Text='<%# Bind("On_Order")%>'></asp:TextBox>                                            </td>                                        </tr>                                        <tr>                                            <td style="color: black; height: 44px;">                                                <strong>Description:</strong></td>                                            <td style="height: 44px">                                            <asp:TextBox ID="Description" runat="server" Text='<%# Bind("Description")%>' Height="53px" TextMode="MultiLine" Width="150px"></asp:TextBox></td>                                        </tr>                                        <tr>                                            <td>                                                <asp:Button ID="EditBtn" runat="server"                                                    Text="Submit Changes" Width="106px" CommandName="Update" /></td>                                            <td>                                                &nbsp;<asp:Button ID="Cancel" runat="server" Text="Cancel" CommandName="cancel" /></td>                                        </tr>                                    </table>                                </EditItemTemplate>                            </asp:FormView>any help would be much appreciated!   

View 1 Replies View Related

Manipulating A SqlDatSource UpdateCommand In Code-behind

Jul 20, 2007

We've got an employee database that I'm modifying to include two photos of each employee, a small thumbnail image and a full-size image.  The HR department maintenance page contains a listbox of employee names, which, when clicked, populates a detailsview control.To get the images to display and be updatable, I've had to structure the following SqlDatasource and DetailsView:
1    <asp:DetailsView ID="dvEmp" runat="server"2      AutoGenerateRows="false"3      DataSourceID="dsEmpView"4      DataKeyNames="empID">5    <Fields>6    <asp:CommandField ShowEditButton="true" ShowCancelButton="true" ShowInsertButton="true" />7    <asp:BoundField HeaderText="Name (Last, First)" DataField="empname" />8    <asp:TemplateField HeaderText="Thumbnail photo">9    <ItemTemplate>10   <asp:Image ID="imgThumbnail" runat="server" ImageUrl='<%# formatThumbURL(DataBinder.Eval(Container.DataItem,"empID")) %>' />11   </ItemTemplate>12   <EditItemTemplate>13   <asp:Image ID="imgThumbHidden" runat="server" ImageUrl='<%# Bind("thumbURL") %>' Visible="false" />14   <asp:FileUpload ID="upldThumbnail" runat="server" />15   </EditItemTemplate>16   </asp:TemplateField>17   <asp:TemplateField HeaderText="Full Photo">18   <ItemTemplate>19   <asp:Image ID="imgPhoto" runat="server" ImageUrl='<%# formatImageURL(DataBinder.Eval(Container.DataItem,"empID")) %>'  />20   </ItemTemplate>21   <EditItemTemplate>22   <asp:Image ID="imgPhotoHidden" runat="server" ImageUrl='<%# Bind("photoURL") %>' Visible="false" />23   <asp:FileUpload ID="upldPhoto" runat="server" />24   </EditItemTemplate>25   </asp:TemplateField>26   </Fields>27   </asp:DetailsView>28   29   <asp:SqlDataSource ID="dsEmpView"30     runat="server"31     ConnectionString="<%$ ConnectionStrings:eSignInConnectionString %>"32     OnInserting="dsEmpView_Inserting"33     OnUpdating="dsEmpView_Updating"34     SelectCommand="SELECT empID, empname, photoURL, thumbURL FROM employees where (empID = @empID)"35     InsertCommand="INSERT INTO employees (empname, photoURL, thumbURL) values(@empname, @photoURL, @thumbURL)"36     UpdateCommand="UPDATE employees SET empname=@empname, photoURL=@photoURL, thumbURL=@thumbURL WHERE (empID = @empID)">37     <SelectParameters>38       <asp:ControlParameter ControlID="lbxEmps" Name="empID" PropertyName="SelectedValue" Type="Int16" />39     </SelectParameters>40   </asp:SqlDataSource>41   42   -----43   44   Protected Sub dsEmpView_Updating(ByVal sender As Object, ByVal e As SqlDataSourceCommandEventArgs)45     Dim bAbort As Boolean = False46     Dim bThumb(), bPhoto() As Byte47     If e.Command.Parameters("@ename").Value.trim = "" Then bAbort = True48     Dim imgT As FileUpload = CType(dvEmp.FindControl("upldThumbnail"), FileUpload)49     If imgT.HasFile Then50       Using reader As BinaryReader = New BinaryReader(imgT.PostedFile.InputStream)51         bThumb = reader.ReadBytes(imgT.PostedFile.ContentLength)52         e.Command.Parameters("@thumbURL").Value = bThumb53       End Using54     End If55     Dim imgP As FileUpload = CType(dvEmp.FindControl("upldPhoto"), FileUpload)56     If imgP.HasFile Then57       Using reader As BinaryReader = New BinaryReader(imgP.PostedFile.InputStream)58         bPhoto = reader.ReadBytes(imgP.PostedFile.ContentLength)59         e.Command.Parameters("@photoURL").Value = bPhoto60       End Using61     End If62     e.Cancel = bAbort63   End SubIf the user updates both images at the same time by populating their respective FileUpload boxes, everything works as advertized.  But if the user only updates one image (or neither image), things break. If they upload, say, just the full-size photo during an update, then it gives the error "System.Data.SqlClient.SqlException: Operand type clash: nvarchar is incompatible with image".I think this error occurs because the update command is trying to set the parameter "thumbURL" without having any actual data to set.  But since I really don't want this image updated with nothing, thereby erasingthe photo already in the database, I'd rather remove this parameter from the update string.So, let's remove the parameter that updates that image by adding the following code just after the "End Using" lines: Else
Dim p As SqlClient.SqlParameter = New SqlClient.SqlParameter("@thumbURL", SqlDbType.Image)
e.Command.Parameters.Remove(p)
(Similar code goes into the code block that handles the photo upload)Running the same update without an image in the thumb fileupload box, I now get this error: "System.ArgumentException: Attempted to remove an SqlParameter that is not contained by this SqlParameterCollection."Huh?  It's not there?  Okay, so lets work it from the other end: let's remove all references to the thumbURL and photoURL from the dsEmpView datasource.  We'll make its UpdateCommand = "UPDATE employees SET empname=@empname WHERE (empID = @empID)", and put code in the dsEmpView_Updating sub that adds the correct parameter to the update command, but only if the fileupload box has something in it.  Therefore: If imgT.HasFile Then
Using reader As BinaryReader = New BinaryReader(imgT.PostedFile.InputStream)
bThumb = reader.ReadBytes(imgT.PostedFile.ContentLength)
e.Command.Parameters.Add(New SqlClient.SqlParameter("@thumbURL", SqlDbType.Image, imgT.PostedFile.ContentLength))
e.Command.Parameters("@thumbURL").Value = bThumb
End Using
End If
(Similar code goes into the code block that handles the photo upload)But reversing the angle of attack only reverses the error. Uploading only the photo and not the thumb image results in: "System.Data.SqlClient.SqlException: The variable name '@photoURL' has already been declared. Variable names must be unique within a query batch or stored procedure."So now it's telling me the parameter IS there, even though I just removed it.ARRRGH!What am I doing wrong, and more importantly, how can I fix it?Thanks in advance. 

View 5 Replies View Related

Dynamic SQL Generation For The UpdateCommand Is Not Supported

Nov 7, 2007

Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.

I am getting the above error if i try to create a update command through a Command builder in .net cf on a SQLCE 3.0 database

The Select query I used for creating the update command is 'SELECT * FROM Users'


I populated a datatable with the above query through a DataAdapter, to check for the primary key and the primary key was available in the table. But still the CB could not able to create an Update Command for that query,

The Primary Key column that I use is of type GUID

Then when try to do the above job using a Typed DataSet with TableAdapters , then it throws the following error

'Update requires a valid UpdateCommand when passed DataRow Collection with modified rows'

can any one please tell me a way to fix this ,

Thanks and Regards
Varadan

View 6 Replies View Related

DetailsView Update With Subquery

Jun 9, 2007

Hi everybody,I have a little Problem with an update and Detailsview.I have 2 table (tblUser - uid,uName,rId) and (tblRole - rId, rDescription) In my update I don't want to use the roles id, I want to use the roles Description.Via sql I do a update the role to Admin like that UPDATE tblUser
SET rId =
(SELECT rId
FROM dbo.tblRoles
WHERE (rDescription = 'Admin')) But I don't get it to work for the detailsview update   

View 4 Replies View Related

Problem With UPDATE With Detailsview

Jul 23, 2007

i get  Incorrect syntax near 'nvarchar'.Must declare the scalar variable "@BookingID".



Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 'nvarchar'.Must declare the scalar variable "@BookingID".

Source Error:





An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.







Stack Trace:




[SqlException (0x80131904): Incorrect syntax near 'nvarchar'.Must declare the scalar variable "@BookingID".] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857354 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734966 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188 ...i am using the Edit feature of the detailsview, seems like the datatype is wrong? ID are int (in my DB, BookingID is int), and also its readonly it should not be updating in the first place right? --------------------------------Any way to debug whats in "new" values? ItemUpdating? how to do it? 

View 3 Replies View Related

Update In DetailsView Not Working

Jun 9, 2008

Hi,
Can anyone tell me why my Update attempts are not working? Here is my code:
<body>
<form id="form1" runat="server">
<div>
 <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px"
AutoGenerateEditButton="True" AutoGenerateRows="False" DataSourceID="SqlDataSource1"
DefaultMode="Edit">
<Fields>
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
</Fields>
</asp:DetailsView><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringListings %>"
SelectCommand="SELECT [City] FROM [Listings]"
UpdateCommand="UPDATE [Listings] Set [City]=@City WHERE [ListingID]=@ListingGuid ">
<UpdateParameters>
<asp:Parameter Name="City" />
<asp:Parameter Name ="ListingGuid" />
</UpdateParameters>
</asp:SqlDataSource>
 
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</div></form>
</body>
And here is my code behindProtected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ListingGuid = Request.QueryString("GUID")
End SubProtected Sub DetailsView1_ItemUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdatedEventArgs) Handles DetailsView1.ItemUpdated
Label1.Text = "updated"
Label2.Text = ListingGuidEnd Sub
Please let me know what I am doing wrong? 
 

View 3 Replies View Related

Edit Function In DetailsView

May 1, 2006

Hello
Am developing a web site using ASP.net 2.0. I have page to manage the employees information in term of viewing, inserting and updating. The problem is that the updating part doesn't work and it didn't give me any error messages.
My code is as following:
<%@ Page Language="VB" AutoEventWireup="false"%>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<script runat="server" >
   
    Protected Sub DetailsView1_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs)
   
        If (Not e.Exception Is Nothing) Then
 
            ErrorMessageLabel.Text = "An error occured while entering this record.  Please verify you have entered data in the correct format."
            e.ExceptionHandled = True
        End If
        GridView1.DataBind()
    End Sub
 
    Protected Sub DetailsView1_ItemUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdatedEventArgs)
   
        GridView1.DataBind()
    End Sub
 
    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
    
        DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
    End Sub
 
    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
   
        DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
    End Sub
 
    Protected Sub GridView1_PageIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
   
        DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
    End Sub
 
    Protected Sub GridView1_Sorted(ByVal sender As Object, ByVal e As System.EventArgs)
        DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
    End Sub
   
</script>
<body dir="rtl">
    <form id="form1" runat="server">
        <br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:warehouse DBConnectionString2 %>"
            ProviderName="<%$ ConnectionStrings:warehouse DBConnectionString2.ProviderName %>"
            SelectCommand="SELECT DISTINCT [dep_Code], [dep_Name], [BRN_Code] FROM [Departments]"></asp:SqlDataSource>
       
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:warehouse DBConnectionString2 %>"
            ProviderName="<%$ ConnectionStrings:warehouse DBConnectionString2.ProviderName %>"
            SelectCommand="SELECT DISTINCT [ID], [Name],[Position], [DEPT_Code] FROM [Employees]
            where [DEPT_Code]=@dep_Name">
        <SelectParameters>
        <asp:ControlParameter ControlID="DropDownList1" Name="dep_Name" Type="Int32" />
        </SelectParameters>
        </asp:SqlDataSource>
       
        <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:warehouse DBConnectionString2 %>"
            ProviderName="<%$ ConnectionStrings:warehouse DBConnectionString2.ProviderName %>"
            SelectCommand="SELECT DISTINCT [ID], [Authentication], [Name], [Password], [Position], [DEPT_Code], [Contact] FROM [Employees]
            where [ID]=@ID "
           
            UpdateCommand="UPDATE [Employees]
                           SET
                           [ID] = @ID,
                             [Authentication]=@Authentication,
                             [Name]=@Name,
                             [Password]=@Password,
                           [Position]=@Position,
                             [DEPT_Code]=@DEPT_Code,
                             [Contact]=@Contact
                           WHERE [ID] = @ID  "
                           
            InsertCommand="INSERT INTO [Employees]
                   ([ID], [Authentication], [Name], [Password], [Position], [DEPT_Code], [Contact])
            Values (@ID, @Authentication, @Name, @Password, @Position, @DEPT_Code, @Contact) "
            >
        <SelectParameters>
        <asp:ControlParameter ControlID="GridView1" Name="ID" Type="Int32"  PropertyName="SelectedValue" />
        </SelectParameters>
       
        <UpdateParameters>
        <asp:Parameter Name="ID" Type="Int32" />
        <asp:Parameter Name="Authentication" Type="Int16" />
        <asp:Parameter Name="Name" Type="String" />
        <asp:Parameter Name="Password" Type="String" />
        <asp:Parameter Name="Position" Type="String" />
        <asp:Parameter Name="DEPT_Code" Type="Int32" />
        <asp:Parameter Name="Contact" Type="String" />
        </UpdateParameters>
       
        <InsertParameters>
        <asp:Parameter Name="ID" Type="Int32" />
        <asp:Parameter Name="Authentication" Type="Int16" />
        <asp:Parameter Name="Name" Type="String" />
        <asp:Parameter Name="Password" Type="String" />
        <asp:Parameter Name="Position" Type="String" />
        <asp:Parameter Name="DEPT_Code" Type="Int32" />
        <asp:Parameter Name="Contact" Type="String" />
        </InsertParameters>
        </asp:SqlDataSource>
        &nbsp;
        <br />
        <br />
        أختر القسم :&nbsp;
        <asp:DropDownList ID="DropDownList1" DataSourceID="SqlDataSource1" AutoPostBack="True"
      DataTextField="dep_Name" runat="server" DataValueField="dep_Code" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" >
        <asp:ListItem></asp:ListItem>
    </asp:DropDownList>
        <table >
            <tr>
                <td style="width: 100px">
                </td>
                <td style="width: 100px">
                </td>
            </tr>
            <tr>
                <td style="width: 100px; height: 154px" valign="top">
                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
                        DataSourceID="SqlDataSource2" AllowPaging="True" AllowSorting="True" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnPageIndexChanged="GridView1_PageIndexChanged">
                        <Columns>
                            <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" />
                           
                            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                            <asp:BoundField DataField="Position" HeaderText="Position" SortExpression="Position" />
                            <asp:BoundField DataField="DEPT_Code" HeaderText="DEPT_Code" SortExpression="DEPT_Code" Visible="False" />
                           
                            <asp:CommandField ShowSelectButton="True" />
                        </Columns>
                    </asp:GridView>
                </td>
                <td style="width: 100px; height: 154px" valign="top">
                    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="ID" OnItemUpdated="DetailsView1_ItemUpdated"
                        DataSourceID="SqlDataSource3" Height="50px" Width="125px" AllowPaging="True" OnItemInserted="DetailsView1_ItemInserted">
                        <Fields>
                            <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" />
                            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                            <asp:BoundField DataField="Password" HeaderText="Password" SortExpression="Password" />
                            <asp:BoundField DataField="Position" HeaderText="Position" SortExpression="Position" />
                            <asp:BoundField DataField="Contact" HeaderText="Contact" SortExpression="Contact" />
                            <asp:TemplateField HeaderText="Department" SortExpression="DEPT_Code" >
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%#Eval("DEPT_Code") %>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource1"
                                    DataTextField="dep_Name" DataValueField="dep_Code" SelectedValue='<%# Bind("DEPT_Code") %>'>
                                    </asp:DropDownList>
                                </EditItemTemplate>
                                <InsertItemTemplate>
                                <asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="SqlDataSource1"
                                DataTextField="dep_Name" DataValueField="dep_Code" SelectedValue='<%# Bind("DEPT_Code") %>'>
                                </asp:DropDownList>
                                </InsertItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Authentication" SortExpression="Authentication">
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%#Eval("Authentication") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:DropDownList ID="DropDownList4" runat="server" SelectedValue='<%# Bind("Authentication") %>'>
                                <asp:ListItem Text="Admin_User" Value="1" />
                                <asp:ListItem Text="Super_User" Value="2" />
                                <asp:ListItem Text="Normal_User" Value="3" />
                                </asp:DropDownList>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                            <asp:DropDownList ID="DropDownList5" runat="server" SelectedValue='<%# Bind("Authentication") %>'>
                                <asp:ListItem Text="Admin_User" Value="1" />
                                <asp:ListItem Text="Super_User" Value="2" />
                                <asp:ListItem Text="Normal_User" Value="3" />
                                </asp:DropDownList>
                            </InsertItemTemplate>
                            </asp:TemplateField>
                            <asp:CommandField ShowInsertButton="True" />
                            <asp:CommandField ShowEditButton="True" />
                        </Fields>
                    </asp:DetailsView>
                </td>
            </tr>
        </table>
      
       <asp:Label ID="ErrorMessageLabel" EnableViewState="false" runat="server" />
    </form>
</body>
</html>
  

View 4 Replies View Related

GridViews/DetailsView (only Appear After Control Selection)

May 5, 2008

Hi all,I want to be able to implement what the following site shows in regards to dynamically displaying Data views of various types: http://quickstarts.asp.net/QuickStartv20/aspnet/samples/data/GridViewMasterDetails_vb.aspx I follow everything to the 'T' but for some reason all my data views are showing even before any initial selection is made in the drop down.  How can I have certain grids appear only after a selection from another control has been made?Thanks in advance,Nick  

View 1 Replies View Related

Images Inside Gridview And Detailsview

Mar 20, 2008

I have been stuck on this problem for over a week, and have ripped out about all of my hair, so here it goes.

I am working on a portfolio on a website that administrators are allowed to update, but the public may only view....easy enough? The grid has three parameters; CatID, Descrip, and Pic - as seen below.


<asp:SqlDataSource ID="SqlDataSource2" runat="server"


ConnectionString="<%$ ConnectionStrings:NORTHWNDConnectionString %>"




SelectCommand="SELECT [CatID], [Descrip], [Pic] FROM [Categories]"




UpdateCommand="UPDATE Categories SET Descrip = @Descrip, Pic = @Pic WHERE CatID = @CatID"

DeleteCommand="DELETE FROM Categories WHERE CatID = @CatID"




InsertCommand="INSERT INTO [Categories] ([CatID], [Descrip], [Pic]) VALUES (@CatID, @Descrip, @Pic)" >



<DeleteParameters>


<asp:Parameter Name="CatID" Type="String" />

<asp:parameter Name="Descrip" />

</DeleteParameters>



<UpdateParameters>


<asp:parameter Name="Descrip" />

<asp:parameter Name="Pic" />

<asp:parameter Name="CatID" Type="String" />

</UpdateParameters>



<insertparameters>


<asp:parameter Name="CatID" Type="String" />

<asp:parameter Name="Descrip" Type="String" />

<asp:parameter Name="Pic" Type="String"/>

</insertparameters>

</asp:SqlDataSource>

The first this I am not sure of, is whether Pic should be a String or not.

Basically I am using Detailsview for the administrator to update, and the gridview for the public view.


<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True"



AutoGenerateRows="False" DataKeyNames="CatID" HeaderText = "Portfolio"

DataSourceID="SqlDataSource2" Height="50px"

Width="300px" Font-Size = "14px" HeaderStyle-Font-Size="Larger" HeaderStyle-BackColor ="#27437D" HeaderStyle-ForeColor = "White"

BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px"

CellPadding="3" GridLines="Vertical">

<footerstyle backcolor="#CCCCCC" forecolor="Black" />

<rowstyle backcolor="#EEEEEE" forecolor="Black" />

<pagerstyle backcolor="#999999" forecolor="Black" horizontalalign="Center" />

<Fields>


<asp:boundfield DataField="CatID" HeaderText="Building/Job Name" ReadOnly="True" SortExpression="CatID">

</asp:boundfield>

<asp:boundfield DataField="Descrip" HeaderText="Description" SortExpression="CompanyName">

</asp:boundfield>

<asp:TemplateField HeaderText="Picture">


<EditItemTemplate>


<asp:TextBox ID="TextBox1" runat="server" Text='<%#Eval("Pic")%>' ></asp:TextBox>

</EditItemTemplate>

<InsertItemTemplate>


<asp:TextBox ID="TextBox1" runat="server" Text='<%#Eval("Pic")%>' ></asp:TextBox>

</InsertItemTemplate>

<ItemTemplate>


<asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("Pic") %>' />

</ItemTemplate>

</asp:TemplateField>

<asp:commandfield ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True">

</asp:commandfield>

</Fields>

<HeaderStyle BackColor="#27437D" Font-Size="Larger" ForeColor="White"></HeaderStyle>

<alternatingrowstyle backcolor="#DCDCDC" />

</asp:DetailsView>

And my Gridview...

<asp:GridView ID= "GridView1" runat="server" DataSourceID="SqlDataSource2" AllowSorting="True" BackColor="White" CellPadding="3" Caption = "Portfolio"


Font-Size ="14px" BorderColor="#999999"BorderStyle="None"BorderWidth="1px"GridLines="Vertical"AutoGenerateColumns="False">

<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />

<RowStyle BackColor="#EEEEEE" Font-Size = "Small" ForeColor="Black" />

<columns>


<asp:boundfield DataField="CatID" HeaderText="Building/Job Name"></asp:boundfield>

<asp:boundfield DataField="Descrip" HeaderText="Description"></asp:boundfield>







<asp:TemplateField HeaderText="Picture">


<EditItemTemplate>


<asp:TextBox ID="TextBox1" runat="server" text='<%# Eval("Pic") %>'

></asp:TextBox>

</EditItemTemplate>

<ItemTemplate>


<asp:Image ID="Image1" runat="server" ImageUrl= '<%# Eval("Pic") %>' />



</ItemTemplate>

</asp:TemplateField>



</columns>

<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />

<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />

<HeaderStyle BackColor="#27437D" Font-Bold="True" ForeColor="White" />

<AlternatingRowStyle BackColor="#DCDCDC" />

</asp:GridView>


Now as I was looking around on the web I saw many people converting the path of the image to binary and the casting it to the DB, and likewise retrieving it from the DB as binary and converting it to an image, the problem is, I don't know how to do this.

Any help to ease my troubles is apprechiated greatly.

Edit: Also I am not totally sure what the '<%Eval("Pic") %>' is doing, it was autofilled for me.
Edit again: Another thing, if I replace any of the ImageUrl to an image path on the computer it does fill the space in the gridview/detailsview. However, with both cases I get a Operand type clash: nvarchar is incompatible with image error.

View 1 Replies View Related

Label Showing User.identity.name In Detailsview

Aug 30, 2007

Hi, any suggestions on why my label doesn't show the current user.identity.name when used in a detailsview (header-field or insert-field), when it works just fine placed directly on my page ?
Please help ! (I want to bind myLabelX.Text to a db-table, but it contains no value..)
codebehind  : 1 using System;
2 using System.Data;
3 using System.Configuration;
4 using System.Collections;
5 using System.Web;
6 using System.Web.Security;
7 using System.Web.UI;
8 using System.Web.UI.WebControls;
9 using System.Web.UI.WebControls.WebParts;
10 using System.Web.UI.HtmlControls;
11
12
13 public partial class Test_2 : System.Web.UI.Page
14 {
15
16 protected void Page_Load(object sender, EventArgs e)
17 {
18 if ((!IsPostBack)) myLabelX.Text = User.Identity.Name;
19 }
20
21 }
 

View 3 Replies View Related

Stored Procdure To Update Two Tables While In Detailsview

Feb 21, 2008

I am using a stored procedure to update data while in detailsview.I am having a rough time. Dont know why this wont workthanks a lotheres my codeALTER PROCEDURE UpdateCustomerInfo    ( @CustomerID as INT, @LName as varchar(50), @FName as varchar(50), @Dept as varchar(50)=NULL, @PhoneType as varchar(50)=NULL, @OfficeType as varchar(50) = NULL, @Ext as Int=NULL, @BridgeExt as int=NULL, @Workstation as varchar(50)=NULL, @OldPrinters as varchar(50)=NULL, @NewPrinters as varchar(50)=NULL, @PhoneImg as varchar(50)=NULL, @OfficeImg as varchar(50)=NULL, @Complete as Bit=NULL, @FaxModel as varchar(50)=NULL, @FaxNumber as varchar(50)=NULL, @ConfPhone as varchar(50)=NULL, @ConfExt as varchar(50)=NULL, @ReutersDacsId as Varchar(50)=NULL, @Bloomberg as Varchar(50)=NULL, @NewFloor as Int=NULL, @OldFloor as Int=NULL )AS    UPDATE CustomerInfo SET LName = @LName, FName = @FName, Dept = @Dept, PhoneType = @PhoneType, Ext = @Ext, BridgeExt = @BridgeExt, Workstation = @Workstation, OldPrinters = @OldPrinters, NewPrinters = @NewPrinters, OfficeImg = @OfficeImg, PhoneImg = @PhoneImg, Complete = @Complete Where CustomerId = @CustomerId        UPDATE Extras SET CustomerID = @CustomerID, FaxModel=@FaxModel, FaxNumber=@FaxNumber, ConfPhone=@ConfPhone, ConfExt=@ConfExt, ReutersDacsId=@ReutersDacsId, Bloomberg=@Bloomberg where CustomerID = @CustomerID        RETURN 

View 2 Replies View Related

Event To Catch A Primary Key Violation In A DetailsView?

Apr 23, 2008

I have a SQLDataSource bound to a DetailsView.  In which event would I catch a Primary Key violation?  Would be an event of the SQLDataSource or the DetailsView?  And which particular event?  A small example would be great.  Thx.

View 1 Replies View Related

Gridview - Updating Is Not Supported By Data Source 'SqlDataSourceGridView' Unless UpdateCommand Is Specified

May 13, 2008

 Hi all,I have a gridview that bound to a SqlDataSource called SqlDataSourceGridView. I have enabled Edit in my GridView, but I do all the updating in code behind with stored procedure (using onRowUpdating). Now each time when I click "Update", the update went through and all the data got updated, but I received this error: Updating is not supported by data source 'SqlDataSourceGridView' unless UpdateCommand is specified.



Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.

Exception Details: System.NotSupportedException:
Updating is not supported by data source 'SqlDataSourceGridView' unless
UpdateCommand is specified. What do I need to do to fix this problem?Thanks a lot. 

View 6 Replies View Related

Detailsview Control - How To Edit Record In Sql Server Express

Aug 25, 2006

I have null values in some of the fields & when I use EDIT to make changes these changes are not recorded + I receive no error.  

View 1 Replies View Related

Insert Works, But Delete And Update Don't In A DetailsView Control

Mar 28, 2008

I have 2 Gridviews and a DetailsView for each GridView. The first Gridview and DetailsView work fine and I can Insert, Delete and Update the DetailsView just fine.  However the second Gridview/DetailsView will only let me Insert but not Delete or Update.  When I click on the "Delete" button it just ignores me.  If I do an "Edit", when I try to click on the "Update" button it is ignored again and I have to click on "Cancel".  I don't get any error messages...
 
Anyone have an idea what might be wrong?

View 4 Replies View Related

Dynamic SQL Generation For The UpdateCommand Is Not Supported Against A SelectCommand That Does Not Return Any Key Column Information.

Feb 1, 2007

Hey,
I changed the database name in the initial cataloge in the web.config conncetion string so that it now connects to other databas that contains same tables as the old one,but now i am getting that error at the update stmt !
thank u in advance
Hiba

View 1 Replies View Related

Hard Coding Colum Names In Returned DetailsView Table

Apr 13, 2007

Hi all,We're selecting data from our database, FirstName, LastName, MobileNumber etc.We're using the detaials view function to return it in a table upon selection. However all of the variables are returned as they are in the database, ie: without spaces. We tried putting in spaces by selecting "AS what ever", but MSSQL does not seem to like spaces.Any ideas?Thanks 

View 2 Replies View Related

Master-Detail W/Gridview-DetailsView Stored Procedure Problem

Oct 26, 2007

 I am attempting to setup a Master-Details with GridView/DetailsView but I can't seem to find any information on using a stored procedure that requires parameters with the SqlDataSource control.  SelectCommandType specifies that you are using a stored proc.  SelectCommand specifies the name of the proc, but I haven't found any information on how to pass a parameter to the stored procedure.Is it even possible or do I have to forget about using the DetailsView control altogether?

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved