Hi, and thanks for responding. That is correct, I do need
to put a
where clause in there, but I am unsure of how to do that.
You say to do
the where clause with the "vauleOfselectedRecord".
How do I go about
calling that from the other datagrid?
Thanks.
Joe
-----Original Message-----
From: Thiam, Alioune (CDC/OCOO/MISO) (CTR) [mailto:ait1 cdc.gov]
Sent: Monday, November 20, 2006 11:34 AM
To: aspnet-datadisplaycontrols aspadvice.com
Subject: [aspnet-datadisplaycontrols] RE: Datagrid and
details button
does not display proper information
Aren't you supposed to have a WHERE clause in this part of
your code?
Something like Dim CommandText As String = "select *
from NSXSystems
where fieldname = valueOfselectedRecord"
Sub dispDetails(sender as Object, e As
DataGridCommandEventArgs)
Dim ConnectionString As String =
"server='labweblabweb';database=LabEquipment;trusted_c
onnection=true"
Dim CommandText As String = "select
* from
NSXSystems"
Dim myConnection As New
SqlConnection(ConnectionString)
Dim mycommand As New
SqlCommand(CommandText,
myConnection)
myConnection.Open()
dgNSXDetails.DataSource =
myCommand.ExecuteReader(CommandBehavior.CloseConnection)
dgNSXDetails.DataBind()
dgNSXDetails.Visible = True
End Sub
-----Original Message-----
From: berthiaume_joe emc.com [mailto:berthiaume_joe emc.com]
Sent: Monday, November 20, 2006 10:49 AM
To: aspnet-datadisplaycontrols aspadvice.com
Subject: [aspnet-datadisplaycontrols] Datagrid and details
button does
not display proper information
Hi All, I am VERY new to ASP.net and am having a problem
that I hope you
can help out with. I have a datagrid that is populated by a
database
with a details button on it. When this details button is
clicked, it is
supposed to go to the same database and display different
information on
the same record. The problem I am having is that when I
press the
details button, the new datagrid comes up and displays the
other
information that I want for all of the database entires, not
just for
the one record that I want it to. I believe I need some SQL
statement,
but I am not sure how to do that. Can anyone please help
out with this?
The primary key field in my database is "Name",
which is a varchar
field. The primary datagrid is "dgNSXSystems" and
the secondary
datagrid is "dgNSXDetails". The code is in this
email. Thanks in
advance for any help you can give me on this matter.
Joe
<% Page Language="VB" %>
<% import Namespace="System.Data" %>
<% import Namespace="System.Data.SqlClient"
%> <script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
If Not Page.IsPostBack then
BindData()
End If
End Sub
Sub BindData()
Dim ConnectionString As String =
"server='labweblabweb';database=LabEquipment;trusted_c
onnection=true"
Dim CommandText As String = "select
* from
NSXSystems"
Dim myConnection As New
SqlConnection(ConnectionString)
Dim mycommand As New
SqlCommand(CommandText,
myConnection)
myConnection.Open()
dgNSXSystems.DataSource =
myCommand.ExecuteReader(CommandBehavior.CloseConnection)
dgNSXSystems.DataBind()
End Sub
Sub dispDetails(sender as Object, e As
DataGridCommandEventArgs)
Dim ConnectionString As String =
"server='labweblabweb';database=LabEquipment;trusted_c
onnection=true"
Dim CommandText As String = "select
* from
NSXSystems"
Dim myConnection As New
SqlConnection(ConnectionString)
Dim mycommand As New
SqlCommand(CommandText,
myConnection)
myConnection.Open()
dgNSXDetails.DataSource =
myCommand.ExecuteReader(CommandBehavior.CloseConnection)
dgNSXDetails.DataBind()
dgNSXDetails.Visible = True
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<asp ataGrid
id="dgNSXDetails" runat="server"
AutoGenerateColumns="False"
CellPadding="3" BackColor="White"
BorderColor="#999999" BorderWidth="1px"
GridLines="Vertical"
BorderStyle="None">
<FooterStyle forecolor="Black"
backcolor="#CCCCCC"></FooterStyle>
<HeaderStyle font-bold="True"
forecolor="White"
backcolor="#000084"></HeaderStyle>
<PagerStyle
horizontalalign="Center"
forecolor="Black"
backcolor="#999999"
mode="NumericPages"></PagerStyle>
<SelectedItemStyle
font-bold="True" forecolor="White"
backcolor="#008A8C"></SelectedItemStyle>
<AlternatingItemStyle
backcolor="#DCDCDC"></AlternatingItemStyle&g
t;
<ItemStyle forecolor="Black"
backcolor="#EEEEEE"></ItemStyle>
<Columns>
<asp:BoundColumn
DataField="Clariion"
HeaderText="Clariion
Type"></asp:BoundColumn>
<asp:BoundColumn
DataField="SPA" HeaderText="SPA
IP"></asp:BoundColumn>
<asp:BoundColumn
DataField="SPB" HeaderText="SPB
IP"></asp:BoundColumn>
<asp:BoundColumn
DataField="Flare" HeaderText="Flare
Code"></asp:BoundColumn>
<asp:BoundColumn
DataField="PersonUsing"
HeaderText="Person
Using"></asp:BoundColumn>
</Columns>
</asp ataGrid&
gt;
</p>
<p>
<asp ataGrid
id="dgNSXSystems" runat="server"
AutoGenerateColumns="False"
CellPadding="3" BackColor="White"
BorderColor="#999999" BorderWidth="1px"
GridLines="Vertical"
BorderStyle="None"
OnItemCommand="dispDetails">
<FooterStyle forecolor="Black"
backcolor="#CCCCCC"></FooterStyle>
<HeaderStyle font-bold="True"
forecolor="White"
backcolor="#000084"></HeaderStyle>
<PagerStyle
horizontalalign="Center"
forecolor="Black"
backcolor="#999999"
mode="NumericPages"></PagerStyle>
<SelectedItemStyle
font-bold="True" forecolor="White"
backcolor="#008A8C"></SelectedItemStyle>
<AlternatingItemStyle
backcolor="Gainsboro"></AlternatingItemStyle
>
<ItemStyle forecolor="Black"
backcolor="#EEEEEE"></ItemStyle>
<Columns>
<asp:ButtonColumn
Text="Details"
ButtonType="PushButton" HeaderText="Clariion
Information"
CommandName="details"></asp:ButtonColumn>
<asp:BoundColumn
DataField="Name"
HeaderText="Name"></asp:BoundColumn>
<asp:BoundColumn
DataField="Type"
HeaderText="Type"></asp:BoundColumn>
<asp:BoundColumn
DataField="cs0IPAddress"
HeaderText="CS0 IP"></asp:BoundColumn>
<asp:BoundColumn
DataField="cs1IPAddress"
HeaderText="CS1 IP"></asp:BoundColumn>
<asp:BoundColumn
DataField="Release"
HeaderText="Release"></asp:BoundColumn>
</Columns>
</asp ataGrid&
gt;
</p>
<p>
</p>
</form>
</body>
</html>
Need SQL Advice? http://sqladvice.com
Need RegEx Advice? http://regexadvice.com
Need XML Advice?
http://xmladvice.com
Need SQL Advice? http://sqladvice.com
Need RegEx Advice? http://regexadvice.com
Need XML Advice? http://xmladvice.com
Need SQL Advice? http://sqladvice.com
Need RegEx Advice? http://regexadvice.com
Need XML Advice? http://xmladvice.com
|