Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 22nd, 2006, 02:24 PM
MDM MDM is offline
Authorized User
 
Join Date: Mar 2006
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamic sql data source

Hi,

attempting to do smth here. got a datagrid, no sql data source attached. Have two hyperlinks above, click each of them makes a relevant dropdown box visible. Content in dropdown lists are data bound to the db.

on selection of the record in dropdown list and the click of the button attempting to attach the sqldata source to the grid. i.e

on click
{
  attach data source to grid
}

it seems as it takes the code in, but sends the error that the grid may not be without an sql data source. As one may see, tricky issue.

suggestions, wise ones?

appreciate that

mdm

 
Old March 22nd, 2006, 03:18 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

what is your code and the name of your datasource?

 
Old April 5th, 2006, 03:59 PM
MDM MDM is offline
Authorized User
 
Join Date: Mar 2006
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Attempt to attach two different data sources depending on the click of the button. Error message - cannot have data grid left un attached (by default)
--------------------------------------------------------------------------------------------------------------------------------------------------

Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        DropDownList1.Visible = True
        DropDownList1.DataValueField = "Language"
        DropDownList1.DataTextField = "Language"
        DropDownList1.DataSourceID = "SqlDataSource2"
        Button1.Visible = True
        GridView1.DataSourceID = "SqlDataSource1"
        DetailsView1.Visible = True


    End Sub

    'Protected Sub LinkButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    ' DropDownList1.Visible = True
    ' DropDownList1.DataValueField = "UserID"
    ' DropDownList1.DataTextField = "UserID"
    'DropDownList1.DataSourceID = "SqlDataSource4"

    'Button1.Visible = True
    'GridView1.DataSourceID = "SqlDataSource5"

    ' DetailsView1.Visible = True
    ' End Sub

 
Old April 5th, 2006, 11:45 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

you need gridview1.datbind after you set the datasource





Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Source Tools to generate XML from SQL data ethanhunt XML 0 May 7th, 2008 02:55 PM
help writing dynamic form data to dynamic table ublend SQL Server ASP 1 June 1st, 2007 08:09 AM
Dynamic Data source with Native XML driver Nellie Crystal Reports 1 November 30th, 2006 11:42 AM
data source and SQL queries sss22 ASP.NET 1.0 and 1.1 Basics 1 October 24th, 2005 01:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.