Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #11 (permalink)  
Old November 23rd, 2008, 12:41 PM
Authorized User
 
Join Date: Nov 2008
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you.
what is the ="<%$ ConnectionStrings:MyConnectionString %>" ?

Is that a claas defined somewhere in C# code?

I'm using vb, how do i connect my connection string with sqldatasource?

thank you

  #12 (permalink)  
Old November 23rd, 2008, 01:47 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Quote:
quote:Originally posted by CyberW
 thank you.
what is the ="<%$ ConnectionStrings:MyConnectionString %>"††?
It's not a language-specific thing. It's just a shortcut way of specifying a connection string you've defined in the <connectionStrings /> section of web.config. Doesn't matter if you're using VB or C#.

If you want, you can actually type your raw connection string into an SqlDataSource, like:

ConnectionString="Data Source=\sqlexpress;Initial Catalog=MyDatabase;Integrated Security=True"

But it is much easier to do it the first way.

_________________________________

Visit my blog at http://leedumond.com
  #13 (permalink)  
Old November 23rd, 2008, 02:21 PM
Authorized User
 
Join Date: Nov 2008
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i'm getting errors putting the CS.

I think i'll pass it & write my own delete command with oledbCommand.

But again, how do i get the specific key from the gridview?

thanks
  #14 (permalink)  
Old November 23rd, 2008, 06:26 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Quote:
quote:Originally posted by CyberW
 i'm getting errors putting the CS.
You didn't type in exactly what I gave you, right? Did you substitute your own values?

_________________________________

Visit my blog at http://leedumond.com
  #15 (permalink)  
Old November 24th, 2008, 05:54 AM
Authorized User
 
Join Date: Nov 2008
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I copy\paste it...

  #16 (permalink)  
Old November 24th, 2008, 10:34 AM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Quote:
quote:Originally posted by CyberW
 I copy\paste it...

Copy / paste won't do it. You have to substitute your own connection string in there. If you can't connect to your own database, then none of this is going to help you at all. There's no way I can guess what that is.

Once you are able to specify the right connection string to YOUR database in the SqlDataSource, the rest of this should be pretty straightforward.

_________________________________

Visit my blog at http://leedumond.com
  #17 (permalink)  
Old November 24th, 2008, 10:41 AM
Authorized User
 
Join Date: Nov 2008
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I trirf to put the access driver ( jet) but it gave me errors ..

Isn't it possible?

also, if i want to write my own handler i cannot get the field values in a specific row of the gridview??

thank u

  #18 (permalink)  
Old November 24th, 2008, 11:03 AM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

I did not know you were using Access, sorry about that. In that case, you'd want to use AccessDataSource, not SqlDataSource.

You can write your own handler, though I don't know what advantage that would provide.

_________________________________

Visit my blog at http://leedumond.com
  #19 (permalink)  
Old November 27th, 2008, 03:02 PM
Authorized User
 
Join Date: Nov 2008
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ikinda lost you..

Can you please write how to put a gridview with a working delete button? ( access db)

thank you

  #20 (permalink)  
Old November 27th, 2008, 05:36 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!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></title>
</head>
<body>
   <form id="form1" runat="server">
      <div>
         <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="True" DataSourceID="AccessDataSource1"
            AutoGenerateDeleteButton="True" DataKeyNames="MyPrimaryKey">
         </asp:GridView>
         <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/MyDatabase.mdb"
            SelectCommand="SELECT * FROM [MyTable]" 
            DeleteCommand="DELETE FROM [MyTable] WHERE [MyPrimaryKey] = ?">
            <DeleteParameters>
               <asp:Parameter Name="MyPrimaryKey" Type="Int32" />
            </DeleteParameters>
         </asp:AccessDataSource>
      </div>
   </form>
</body>
</html>
Don't forget to substitute your OWN values for MyPrimaryKey, MyDatabase, and MyTable.

_________________________________

Visit my blog at http://leedumond.com
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using command buttons in Access kelljw Access VBA 10 July 5th, 2006 01:42 PM
Using command buttons in Access kelljw BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 1 July 4th, 2006 08:21 AM
Labels as command buttons RichMW Access VBA 0 February 18th, 2005 09:10 AM
Graphics For Command Buttons Teqlump Access 1 November 24th, 2004 11:02 AM
Datagrid command buttons badgolfer ASP.NET 1.0 and 1.1 Basics 22 July 27th, 2004 03:42 AM



All times are GMT -4. The time now is 06:55 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.