CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > visual_studio.visual_studio_2005 Tags:
Item Type: NewsGroup Date Entered: 11/26/2007 8:44:52 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 11 Views: 57 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
12 Items, 1 Pages 1 |< << Go >> >|
number8bus
Asp.Net User
Debugging asp:SqlDataSource11/26/2007 8:44:52 PM

0/0

Hi there,

I'm using <asp:SqlDataSource> to connect to a database and update a record in a gridview.

The problem is my data is not updating.  In the past with 1.1 I could easily debug code with Datagrid, but because I'm using asp:SqlDataSource I cannot add breakpoints.

How can I debug this part of the code and see why my table is not updating.

Many thanks


- Working with ASP.NET 2.0 using VB and C#.
Mikesdotnetting
Asp.Net User
Re: Debugging asp:SqlDataSource11/26/2007 8:50:41 PM

0/0

You can create Updating and Updated event handlers for the SqlDataSource and stick breakpoints in those to see if either are hit.

 


Regards Mike

8 out of 10 questions have already been asked. Their answers can be found using Google. Go on, try it.

If you prefer code samples or tutorials in another language, translate it for free at www.codechanger.com
moises.dl
Asp.Net User
Re: Debugging asp:SqlDataSource11/26/2007 8:51:14 PM

0/0

my suggestion is to wire up the onupdating event and then look at your parameters and their values make sure you have all the default values set, and check to see if they are named right, moreover make sure youre sproc works in sql therefore you know its not the sql. but hopefully everything you need will be in that event.


Thanks A Bunch
number8bus
Asp.Net User
Re: Debugging asp:SqlDataSource11/28/2007 9:08:05 PM

1/1

Thanks.

Would you have an example of using OnUpdating to display parameters that I'm defining in asp:sqldatasource?

 


- Working with ASP.NET 2.0 using VB and C#.
Mikesdotnetting
Asp.Net User
Re: Debugging asp:SqlDataSource11/28/2007 9:28:44 PM

0/0

If you select the datasource in design view, you can get to its events via the Properties panel.  Just click the lightning icon.  Double click the Updating event, and that will create the event handler code.  Within that do this:

foreach(SqlParameter p in e.Command.Parameters)
{
    Response.Write(p.ParameterName + ": " + p.Value + "<br />");
}
 


Regards Mike

8 out of 10 questions have already been asked. Their answers can be found using Google. Go on, try it.

If you prefer code samples or tutorials in another language, translate it for free at www.codechanger.com
number8bus
Asp.Net User
Re: Debugging asp:SqlDataSource11/28/2007 9:50:09 PM

0/0

Thanks Mike.

My parameters are displaying the correct data that I'm entering in the gridview, but my database isn't, so my gridview is retrieving old data.

Any ideas why?  Do I need to bind like you do with 1.1 datagrid?

Thanks.


- Working with ASP.NET 2.0 using VB and C#.
Mikesdotnetting
Asp.Net User
Re: Debugging asp:SqlDataSource11/28/2007 10:07:34 PM

0/0

No.  The SqlDataSource should take care of that.  Post your aspx code (just the relevant portions).

 


Regards Mike

8 out of 10 questions have already been asked. Their answers can be found using Google. Go on, try it.

If you prefer code samples or tutorials in another language, translate it for free at www.codechanger.com
moises.dl
Asp.Net User
Re: Debugging asp:SqlDataSource11/28/2007 10:23:07 PM

0/0

sometimes trying to get those magic parameters to work can be a B&*$$ so what i do sometimes is in your gridview make your fields that you are updating template fields then you can name the texboxes whatever you want (i know this is work but thats why you get paid $$$$$ (ding ding sound) . once you do that on updating you can set your default values of your parameters to your texbox values, moreover this also gives you the opportunity to do some sweet validation client and server side. let me holla at you real quick and show you what i mean

 (i cant cut and paste images soooo... i hope you know how to do this.) but its in the smart tag of the gridview then select your field then click the link that says (change to template) then again on your smart tag of your gridview go to edit template fields, on that drop down select your new template field and go to the "edit" box and name that textbox something appropriate, now on updatingyou can set the default value... (im not sure if this is going to help becuase it sounds like your gridview is getting its data from some other place but its a suggestion)

 

by the way try it with one field before you change your whole gridview

 


Thanks A Bunch
moises.dl
Asp.Net User
Re: Debugging asp:SqlDataSource11/28/2007 10:28:00 PM

0/0

make sure your update works too just in sql


Thanks A Bunch
number8bus
Asp.Net User
Re: Debugging asp:SqlDataSource11/28/2007 10:36:19 PM

0/0

aspx code:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
            AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
            <Columns>
                <asp:CommandField ShowSelectButton="True" />
                <asp:CommandField ShowEditButton="True" />
                <asp:CommandField ShowDeleteButton="True" />
                <asp:BoundField DataField="taskname" HeaderText="taskname" SortExpression="taskname" NullDisplayText="N/A" />
                <asp:BoundField DataField="taskdescription" HeaderText="taskdescription" SortExpression="taskdescription" NullDisplayText="N/A" />
                <asp:BoundField DataField="taskstatus" HeaderText="taskstatus" SortExpression="taskstatus" NullDisplayText="N/A" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Taskdb %>"
            SelectCommand="SELECT [taskid], [taskname], [taskdescription], [taskstatus] FROM [tblTask]" UpdateCommand="UPDATE [tbltask] set [taskname] = @taskname, [taskdescription] = @taskdescription, [taskstatus] = @taskstatus where [taskid] = @taskid" OnUpdated="OnUpdated" OnUpdating="SqlDataSource1_Updating">
            <UpdateParameters>
                <asp:Parameter Type="String" Name="taskname" />
                <asp:Parameter Type="String" Name="taskdescription" />
                <asp:Parameter Type="Int32" Name="taskstatus" />
                <asp:Parameter Type="Int32" Name="taskid" />
            </UpdateParameters>
        </asp:SqlDataSource>

- Working with ASP.NET 2.0 using VB and C#.
Mikesdotnetting
Asp.Net User
Re: Debugging asp:SqlDataSource11/29/2007 7:30:42 AM

0/0

Looks like you are missing the DataKeyNames attribute.

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" DataKeyNames="taskid"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1">

Regards Mike

8 out of 10 questions have already been asked. Their answers can be found using Google. Go on, try it.

If you prefer code samples or tutorials in another language, translate it for free at www.codechanger.com
number8bus
Asp.Net User
Re: Debugging asp:SqlDataSource11/29/2007 7:12:59 PM

0/0

It's working, thanks Mike.


- Working with ASP.NET 2.0 using VB and C#.
12 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Programming ASP.NET: Building Web Applications and Services with ASP.NET 2.0 Authors: Jesse Liberty, Dan Hurwitz, Pages: 930, Published: 2005
Professional ASP.NET 2.0 Authors: Bill Evjen, Scott Hanselman, Farhan Muhammad, Srinivasa Sivakumar, Devin Rader, Pages: 1253, Published: 2005
Pro ASP.NET 3.5 in C# 2008 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1498, Published: 2007
Pro ASP.NET 2.0 in VB 2005: From Professional to Expert Authors: Laurence Moroney, Matthew MacDonald, Pages: 1253, Published: 2006
Beginning ASP.NET 3.5 in C# 2008: From Novice to Professional Authors: Matthew MacDonald, Pages: 954, Published: 2007
Pro ASP.NET 2.0 in C# 2005 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1255, Published: 2005
Pro ASP.NET 2.0 in C# 2005: Create Next-generation Web Applications with the Latest Version of Microsoft's Revolutionary Technology Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1426, Published: 2006
Programming Visual Basic 2005 Authors: Jesse Liberty, Pages: 548, Published: 2005
Beginning ASP.NET 2.0 with C# Authors: Chris Hart, John Kauffman, David Sussman, Chris Ullman, Pages: 735, Published: 2006
Beginning ASP.NET 2.0 in VB 2005: From Novice to Professional Authors: Matthew MacDonald, Pages: 1063, Published: 2006

Web:
Debugging asp:SqlDataSource - ASP.NET Forums In the past with 1.1 I could easily debug code with Datagrid, but because I'm using asp:SqlDataSource I cannot add breakpoints. ...
SqlDataSource and actual sql text going to db ASP Net - SqlDataSource and actual sql text going to db ... For my debugging purpose I would like to see the actual sql text going ...
FormView and GridView does not appear when i debug - ASP.NET FormView and GridView does not appear when i debug - ASP. ... ForeColor="#284775 " /> AzamSharp : TIP/TRICK SqlDataSource Parameter Names Nov 28, 2006 ... Passing a outside variable into a tag. ASP.NET ... SqlDataSource and Wizard control - ASP.NET Forums Blog: Prototyping in ASP.Net - asp:SqlDataSource Example Apr 16, 2008 ... Assign SelectedValue to DropDownList from code-behind file using ... DataValueField="ID">




Search This Site:










help with designer.vb files

is it the error or my code?

will 2.0 upgrade 1.10?

datatextfield & group element of profile

site samples

new skin: clouds (something very different)

help :-( it doesnt work

menu control - how do i hide the popout image ?

adding custom module to page

is install order important? vs 2005, sql server 2005 - release versions

localization of left nav items

drop down list selected text

cookie and sliding expiration

page size question

intructions?

help - can't create http web sites

error:name 'ucase' not declared webpart vs 2005

dynamic buttons on content page

is there a c# version

building in .net 1.1

asp.net exploring.

including common code in many pages

itemdatabound for datagrid control validation

iframes

remote sql server

portal security in new aspx pages

problem with control rendering in design view

dnn upgrade problems

com works in vb.net, not c#??

design view of sqldatasource control

 
All Times Are GMT