Subject: Dynamic sql data source
Posted By: MDM Post Date: 3/22/2006 1:24:45 PM
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

Reply By: jbenson001 Reply Date: 3/22/2006 2:18:54 PM
what is your code and the name of your datasource?

Reply By: MDM Reply Date: 4/5/2006 3:59:43 PM
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

Reply By: jbenson001 Reply Date: 4/5/2006 11:45:16 PM
you need gridview1.datbind after you set the datasource


Go to topic 42501

Return to index page 322
Return to index page 321
Return to index page 320
Return to index page 319
Return to index page 318
Return to index page 317
Return to index page 316
Return to index page 315
Return to index page 314
Return to index page 313