Hi all, I'm having trouble with my datagrid, it is suppose to display a row
from a table called "Calls" based on what is selected in the dropdownlist
which displays the first and last name from another table called "Contacts".
The problem is only the dropdownlist is showing in the browser and nothing
from the datagrid shows.
Could someone please point out my error, I am new at this, and would
appreciate some help.
thanks,
student
Here's the code:
Imports System.Data.Sql Client
Imports System.Data
Public Class WebForm1
Inherits System.Web.UI.P age
Protected WithEvents SqlSelectComman d1 As
System.Data.Sql Client.SqlComma nd
Protected WithEvents SqlInsertComman d1 As
System.Data.Sql Client.SqlComma nd
Protected WithEvents SqlUpdateComman d1 As
System.Data.Sql Client.SqlComma nd
Protected WithEvents SqlDeleteComman d1 As
System.Data.Sql Client.SqlComma nd
Protected WithEvents SqlSelectComman d2 As
System.Data.Sql Client.SqlComma nd
Protected WithEvents SqlInsertComman d2 As
System.Data.Sql Client.SqlComma nd
Protected WithEvents SqlUpdateComman d2 As
System.Data.Sql Client.SqlComma nd
Protected WithEvents SqlDeleteComman d2 As
System.Data.Sql Client.SqlComma nd
Protected WithEvents ContactMgmt As System.Data.Sql Client.SqlConne ction
Protected WithEvents adptCalls As System.Data.Sql Client.SqlDataA dapter
Protected WithEvents adptContacts As
System.Data.Sql Client.SqlDataA dapter
Protected WithEvents dsCalls As figure5_22.Data Set1
Protected WithEvents dsContacts As figure5_22.Data Set2
Protected WithEvents grdCalls As System.Web.UI.W ebControls.Data Grid
Protected WithEvents drpContacts As
System.Web.UI.W ebControls.Drop DownList
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
'Run the first time the page is displayed.
If Not IsPostBack Then
'fill the contacts data set.
adptContacts.Fi ll(dsContacts)
'for each row in the table...
Dim drowItem As DataSet2.Contac tsRow
For Each drowItem In dsContacts.Cont acts
'create a new list item
Dim lstnew As New ListItem()
lstnew.Text = drowItem.FirstN ame & " " & drowItem.LastNa me
lstnew.Value = drowItem.Contac tID
'add the list item to the drop-down list.
drpContacts.Ite ms.Add(lstnew)
Next
End If
End Sub
Private Sub drpContacts_Sel ectedIndexChang ed(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
drpContacts.Sel ectedIndexChang ed
'When a contact is selected, display the contact's calls
adptCalls.Selec tCommand.Comman dText = "SELECT * FROM Calls" & _
"WHERE ContactID =" & drpContacts.Sel ectedItem.Value
'Clear the data set.
dsCalls.Clear()
adptCalls.Fill( dsCalls)
'Display the results in a data grid.
grdCalls.DataBi nd()
End Sub
End Class 2 1167
"student" <mr********@yah oo.com> wrote in message
news:ht******** *********@newss vr17.news.prodi gy.com... Hi all, I'm having trouble with my datagrid, it is suppose to display a row from a table called "Calls" based on what is selected in the dropdownlist which displays the first and last name from another table called "Contacts". The problem is only the dropdownlist is showing in the browser and nothing from the datagrid shows. Could someone please point out my error, I am new at this, and would appreciate some help.
Are you sure that the DataSource and DataMember are set in the datagrid? Are
you sure that the Fill is returning rows?
John Saunders
In the page_load you are not binding datagrid itself. so it wont come in the
browser. If you want to bring the datagrid in the browser when page loads,
bind it with datasource filtered using default value of dropdownlist
selection.
--
Saravana http://dotnetjunkies.com/WebLog/saravana/ www.ExtremeExperts.com
"student" <mr********@yah oo.com> wrote in message
news:ht******** *********@newss vr17.news.prodi gy.com... Hi all, I'm having trouble with my datagrid, it is suppose to display a
row from a table called "Calls" based on what is selected in the dropdownlist which displays the first and last name from another table called
"Contacts". The problem is only the dropdownlist is showing in the browser and nothing from the datagrid shows. Could someone please point out my error, I am new at this, and would appreciate some help. thanks, student Here's the code: Imports System.Data.Sql Client Imports System.Data Public Class WebForm1 Inherits System.Web.UI.P age Protected WithEvents SqlSelectComman d1 As System.Data.Sql Client.SqlComma nd Protected WithEvents SqlInsertComman d1 As System.Data.Sql Client.SqlComma nd Protected WithEvents SqlUpdateComman d1 As System.Data.Sql Client.SqlComma nd Protected WithEvents SqlDeleteComman d1 As System.Data.Sql Client.SqlComma nd Protected WithEvents SqlSelectComman d2 As System.Data.Sql Client.SqlComma nd Protected WithEvents SqlInsertComman d2 As System.Data.Sql Client.SqlComma nd Protected WithEvents SqlUpdateComman d2 As System.Data.Sql Client.SqlComma nd Protected WithEvents SqlDeleteComman d2 As System.Data.Sql Client.SqlComma nd Protected WithEvents ContactMgmt As
System.Data.Sql Client.SqlConne ction Protected WithEvents adptCalls As System.Data.Sql Client.SqlDataA dapter Protected WithEvents adptContacts As System.Data.Sql Client.SqlDataA dapter Protected WithEvents dsCalls As figure5_22.Data Set1 Protected WithEvents dsContacts As figure5_22.Data Set2 Protected WithEvents grdCalls As System.Web.UI.W ebControls.Data Grid Protected WithEvents drpContacts As System.Web.UI.W ebControls.Drop DownList
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load 'Put user code to initialize the page here 'Run the first time the page is displayed. If Not IsPostBack Then 'fill the contacts data set. adptContacts.Fi ll(dsContacts) 'for each row in the table... Dim drowItem As DataSet2.Contac tsRow For Each drowItem In dsContacts.Cont acts 'create a new list item Dim lstnew As New ListItem() lstnew.Text = drowItem.FirstN ame & " " & drowItem.LastNa me lstnew.Value = drowItem.Contac tID 'add the list item to the drop-down list. drpContacts.Ite ms.Add(lstnew) Next End If End Sub
Private Sub drpContacts_Sel ectedIndexChang ed(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles drpContacts.Sel ectedIndexChang ed
'When a contact is selected, display the contact's calls adptCalls.Selec tCommand.Comman dText = "SELECT * FROM Calls" & _ "WHERE ContactID =" & drpContacts.Sel ectedItem.Value 'Clear the data set. dsCalls.Clear() adptCalls.Fill( dsCalls) 'Display the results in a data grid. grdCalls.DataBi nd() End Sub End Class
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Junkguy |
last post by:
I need some help programmatically causing a row in a DataGrid to "flush"
its contents to its bound data (in Visual Studio 6 using Windows Forms
with C#).
My issue is I want to send an update to a database from a menu command
while the user is editing a DataGrid. This is unusual in regard to
examples and normal practice in that the cell of the DataGrid still has
the focus. In all examples I can find, the user normally presses a
button on...
|
by: MrNobody |
last post by:
I am desperately in need of some help to get a summary row for my DataGrid. A
summary row is just a row always on the bottom which has totals for certain
columns.
I have been able to find tutorials online that show exactly how to
accomplish this using the Web UI DataGrid in ASP.net, but unfortunately the
DataGrids are simply not the same- the Windows.Forms DataGrid does not have a
footer you can use like the Web UI one has
So far the...
|
by: ericm1155 |
last post by:
I am trying to display some information from a database in a form that
displays one record per line. When the user clicks anywhere on a line, that
record is highlighted and selected, and my program will respond to that. The
problem is that with a listbox control (which is what it sounds like I need),
I can't get the information to format at all. \t-Tabs skew the data
unpredicatably - it leaves some words closer together on some lines than...
|
by: Luis E Valencia |
last post by:
I need a link on a datagrid, the link must have fields of the database
Like this
acciones.aspx?iddireccion=1&idindicador=4
Thanks
|
by: Jennyfer J Barco |
last post by:
Hello again I have a datagrid and I'm showing many records. I need 2 things:
I need that everytime they scroll down, the header stays lock so the user
can see it all the time. I need to scroll only the data and keep the header
stationary. Is this possible?
Second the user has a search bottom and a textbox and when he inserts a
value my program selects the row (using MyGrid.SelectedIndex) that matches
the value the user entered. If the...
| |
by: Anna |
last post by:
I have a simple DataGrid that displays a list of characteristics and
allows you to edit a description for each characteristic. The query
that feeds this involves a join, as the characteristics and their
descriptions are in separate tables. The DataKeyField of the DataGrid
is set to the description ID, but I also need to be able to access the
characteristic ID in my update query (without displaying it in the
DataGrid). I haven't had much...
|
by: Terry Olsen |
last post by:
I've got a datagrid set up to display data. I've also got an
Edit,Update,Cancel column set up to allow editing of data.
I've got a DropDownList (ID="ddl3")in the EditItemTemplate for a certain
column that I need to populate while in Edit Mode.
Two questions: Is there a way to directly use another DropDownList as a
DataSource? If so how?
I'm using the following code to try to populate the DropDownList, but
|
by: coleenholley |
last post by:
I've been trying since last Friday to get an answer on how to get a SPECIFIC row.cell value from a datagrid. I've had plenty of suggestions, but nothing works to get the value from a SPECIFIC Row and cell. Right now I have this code
Sub Item_Bound(ByVal sender As Object, ByVal e As DataGridItemEventArgs
lbl_test.Text = lbl_test.Text & " " & e.Item.ItemInde
Session("wa_tot_gal") = e.Item.Cells(7).Tex
Response.Write(Session("wa_tot_gal")...
|
by: Larry Woods |
last post by:
I have a datagrid that is carrying all fields of a record...except one. Now
I want to update the underlying database via a dataadapter. The update is
working but the field that is "left out" is not there, of course. How do I
get that field back into the datatable for the database update?
TIA,
Larry Woods
|
by: Familjen Karlsson |
last post by:
Hi
I have downloaded some code and tried it and nothing happens with the
datagrid. Explain what is wrong and what I have to do please. I have tried
to Import the namespace Hamster and it didn't work. Explain what I have to
do to make that work.
Fia
Imports System
Imports System.Windows.Forms
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |