Als ik een record wil tovoegen aan mijn datagrid ... dan geeft hij telkens lege waarden in in de datagrid
iemand een idee?
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
| <%@ Page Language="C#" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Text" %>
<%@ import Namespace="System.Data.Odbc" %>
<script runat="server">
protected void Page_Load(Object Src, EventArgs E)
{
// Maak eerst de connectie...
OdbcConnection DBTIConnectie = new OdbcConnection("DSN=xxxxxx");
//.. open dan..
DBTIConnectie.Open();
if (!IsPostBack)
{
BindGrid();
}
}
public void BindGrid()
{
// Maak eerst de connectie...
OdbcConnection DBTIConnectie = new OdbcConnection("DSN=xxxxxxxx");
// Connect to the database with a SELECT query on the
// "Authors" table.
OdbcDataAdapter myCommand = new OdbcDataAdapter("SELECT * FROM bieden", DBTIConnectie);
// Create and fill a new DataSet.
DataSet ds = new DataSet();
myCommand.Fill(ds);
// Bind MyDataGrid to the DataSet.
MyDataGrid.DataSource=ds;
MyDataGrid.DataBind();
}
public void AddAuthor_Click(object sender, EventArgs e) {
if (IBodTitelObj.Value == "" || IBodBeschrijving.Value == "")
{
BindGrid();
return;
}
// Maak eerst de connectie...
OdbcConnection DBTIConnectie = new OdbcConnection("DSN=2TI_MAXIMMO");
String insertCmd = "insert into bieden (BodTitelObj,BodBeschrijving,BodAantal,GebouwID,BodBieder) values (@IBodTitelObj," +
" @IBodBeschrijving, @IBodAantal, @IGebouwID, @IBodBieder)";
OdbcCommand DBTICommand = new OdbcCommand(insertCmd, DBTIConnectie);
DBTICommand.Connection.Open();
DBTICommand.Parameters.Add(new OdbcParameter("@IBodTitelObj",OdbcType.VarChar, 30));
DBTICommand.Parameters["@IBodTitelObj"].Value = IBodTitelObj.Value;
DBTICommand.Parameters.Add(new OdbcParameter("@IBodBeschrijving",OdbcType.VarChar, 200));
DBTICommand.Parameters["@IBodBeschrijving"].Value = IBodBeschrijving.Value;
DBTICommand.Parameters.Add(new OdbcParameter("@IBodAantal",OdbcType.Int, 3));
DBTICommand.Parameters["@IBodAantal"].Value = IBodAantal.Value;
DBTICommand.Parameters.Add(new OdbcParameter("@IGebouwID",OdbcType.Int, 5));
DBTICommand.Parameters["@IGebouwID"].Value = IGebouwID.Value;
DBTICommand.Parameters.Add(new OdbcParameter("@IBodBieder",OdbcType.VarChar, 30));
DBTICommand.Parameters["@IBodBieder"].Value = IBodBieder.Value;
DBTICommand.ExecuteNonQuery();
DBTICommand.Connection.Close();
BindGrid();
}
</script>
<html>
<head>
</head>
<body style="FONT: 10pt verdana">
<%-- Display the DataGrid in the body of the page, and create and display the input form. --%>
<form runat="server">
<h3><font face="Verdana">Tabel Biedingen</font>
</h3>
<table width="95%">
<tbody>
<tr>
<td valign="top">
<%-- Put the DataGrid in the first column. --%>
<ASP:DataGrid id="MyDataGrid" runat="server" Width="700" BackColor="#ccccff" BorderColor="black" ShowFooter="false" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" EnableViewState="false"></ASP:DataGrid>
</td>
</tr>
</tbody>
</table>
<br />
<table bordercolor="#404000">
<tbody>
<tr>
<%-- Create a second table column. --%>
<td valign="top">
<%-- Put the input form (a second table) in the second column. --%>
<table style="FONT: 8pt verdana" bordercolor="#400000">
<tbody>
<tr>
<td style="FONT: 10pt verdana" bgcolor="#aaaadd" colspan="2">
Ingeven van nieuwe data:
</td>
</tr>
<tr>
<td nowrap="nowrap">
Titel object:</td>
<td>
<input id="IBodTitelObj" type="text" runat="server" /></td>
</tr>
<tr>
<td nowrap="nowrap">
Omschrijving object:</td>
<td>
<input id="IBodBeschrijving" type="text" runat="server" /></td>
</tr>
<tr>
<td nowrap="nowrap">
Gebouw id :
</td>
<td>
<input id="IGebouwID" type="text" runat="server" /></td>
</tr>
<tr>
<td nowrap="nowrap">
Bod aantal :
</td>
<td>
<input id="IBodAantal" type="text" runat="server" /></td>
</tr>
<tr>
<td nowrap="nowrap">
Bod Bieder :</td>
<td>
<input id="IBodBieder" type="text" runat="server" /></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>
</td>
<td style="PADDING-TOP: 15px">
<input type="submit" value="Voeg toe!" runat="server" onserverclick="AddAuthor_Click" />
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html> |
iemand een idee?
[ Voor 14% gewijzigd door Verwijderd op 01-04-2004 11:03 ]