adding to the end of DataGrid

  • shikozel
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Jan 25, 2004
  • Posts: 49
  • Status: Offline

Post March 13th, 2004, 11:07 am

After I am using SELECT method I want to use another SELECT and add the returned result to the end of the DataGrid
Any idea :cry:
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post March 13th, 2004, 11:07 am

  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Joined: Feb 17, 2004
  • Posts: 279
  • Loc: Buenos Aires, Argentina
  • Status: Offline

Post March 13th, 2004, 12:08 pm

If you really want some help, then take the time to explain the problem including the code you are working on, the language you are using for it, etc.
  • shikozel
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Jan 25, 2004
  • Posts: 49
  • Status: Offline

Post March 13th, 2004, 1:09 pm

I will rephrase my question.

The user is picking by List of CheckBoxList
When the user press the submit button I will show on DataGrid the selcted item.
In my code I check if specific checkBox is Selected. if it does call SELECT method and present it on DstsGrid. Then I check the next selected CheckBox. If it selected call SELECT method and present it on the DataGrid. When I am doing so, I am overwriting the previous information on the DataGrid.

Here is my code( here I use a repeater):

<%@ Page Language="VB" %>
<%@ Register TagPrefix="wmx" Namespace="Microsoft.Matrix.Framework.Web.UI" Assembly="Microsoft.Matrix.Framework, Version=0.6.0.0, Culture=neutral, PublicKeyToken=6f763c9966660626" %>
<script runat="server">

Function getPrices(ByVal name As String) As System.Data.IDataReader
Dim connectionString As String = "server='(local)'; trusted_connection=true; database='FrenchRoast'"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)


Dim queryString As String = "SELECT [Produce].[Name], [Produce].[Size], [Produce].[Gramercy], [Produce].[Baybe"& _
"rry], [Produce].[FoodAuth] FROM [Produce] WHERE ([Produce].[Name]=@name "
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_name As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_name.ParameterName = "@Name"
dbParam_name.Value = name
dbParam_name.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_name)

dbConnection.Open
Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

Return dataReader
End Function

Function list() As String
Dim l As String="'Avocado','Cabbage'"
return l

End Function

Sub Button1_Click_1(sender As Object, e As EventArgs)
DataList.DataSource=MyQueryMethod("avocado")
DataList.DataBind()

End Sub


Function MyQueryMethod(ByVal name As String) As System.Data.DataSet
Dim connectionString As String = "server='(local)'; trusted_connection=true; database='FrenchRoast'"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)

Dim queryString As String = "SELECT [Produce].* FROM [Produce] WHERE ([Produce].[Name] IN @Name)"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_name As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_name.ParameterName = "@Name"
dbParam_name.Value = name
dbParam_name.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_name)

Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)

Return dataSet
End Function

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
<asp:CheckBox id="Avocado" runat="server" Text="Avocado"></asp:CheckBox>
</p>
<p>
<asp:CheckBox id="BeetsLoose" runat="server" Text="Beets Loose"></asp:CheckBox>
</p>
<p>
<asp:CheckBox id="Cabbage" runat="server" Text="Cabbage"></asp:CheckBox>
</p>
<p>
<asp:Button id="Button1" onclick="Button1_Click_1" runat="server" Text="Button"></asp:Button>
</p>
<p>
</p>
<p>
<ASP:Repeater id="DataList" runat="server">
<HeaderTemplate>
<table width="100%" style="font: 8pt verdana">
<tr style="background-color:DFA894">
<th>
Name
</th>
<th>
Size
</th>
<th>
Gramercy
</th>
<th>
Bayberry
</th>
<th>
Food Auth
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="background-color:FFECD8">
<td>
<%# DataBinder.Eval(Container.DataItem, "Name") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Size") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "Gramercy", "$ {0}") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "BayBerry", "$ {0}") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "FoodAuth", "$ {0}") %>
</td>
</tr>
</ItemTemplate>
</ASP:Repeater>
</p>
<!-- Insert content here -->
</form>
</body>
</html>

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 144 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.