Click to See Complete Forum and Search --> : Please Help: Datagrid and Checkboxes


macker
05-09-2007, 12:07 PM
I have a datagrid populated with data from a table in a sql database.

I have added a column in the gridview to display checkboxes.

When the checkbox is selected, and a button on the bottom of the page is clicked, I want the selected records to transfer to a different datagrid.

Right now, it is simply putting the values from each cell in a textbox. This will not work.

This second datagrid will be editable.

How do I transfer these selected records to the second datagrid????

Any help would be wonderful. Thank you



Code for datagrid::::

<asp: DataGrid ID="CommGridSavingRates" runat="server" style="text-align:center; word-break:keep-all" AutoGenerateColumns="False" TabIndex="9" CellPadding="4" GridLines="None" ForeColor="#333333" ><FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" />

<SelectedItemStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />

<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />

<AlternatingItemStyle BackColor="White" ForeColor="#284775" />

<ItemStyle BackColor="#F7F6F3" ForeColor="#333333" />

<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />

<Columns>

<asp:BoundColumn HeaderText="catID" Visible="False"></asp:BoundColumn>

<asp:BoundColumn DataField="catID" HeaderText="ID" SortExpression="catID"

Visible="False">

<ItemStyle HorizontalAlign="Right" />

</asp:BoundColumn>

<asp:BoundColumn DataField="depositType" HeaderText="Type of Deposit" SortExpression="Type of Deposit">

</asp:BoundColumn>

<asp:BoundColumn DataField="minToOpen" HeaderText="Minimum Amount to Open Account"></asp:BoundColumn>

<asp:BoundColumn DataField="maturity" HeaderText="Maturity"></asp:BoundColumn>

<asp:BoundColumn DataField="minBalanceToEarn" HeaderText="Minimum Balance to Earn APY">

</asp:BoundColumn>

<asp:BoundColumn DataField="interestRate" HeaderText="Interest Rate %"></asp:BoundColumn>

<asp:BoundColumn DataField="APY" HeaderText="Annual Percentage Yield % (APY)" ></asp:BoundColumn>

<asp:boundColumn DataField="compFreq" HeaderText="Compounding Frequency"></asp:BoundColumn>

<asp:TemplateColumn HeaderText="Edit Selection" HeaderStyle-HorizontalAlign="center">

<ItemTemplate>

<asp:CheckBox id="editSavings" runat="server" checked="true"/>

</ItemTemplate>

</asp:TemplateColumn>

</Columns>

<EditItemStyle BackColor="#999999" />

</asp: DataGrid>





Code for .vb file:::::

Private Sub Checker()

' Count the number of selected items in the DataGrid control.

Dim count As Integer = 0

' Display the selected times.

'txtRecord.Text = "You Selected: <br>"

' Iterate through each item (row) in the DataGrid control and

' determine whether it is selected.

Dim item As DataGridItem

For Each item In CommGridSavingRates.Items

DetermineSelection(item, count)

Next

' If no items are selected, display the appropriate message.

If count = 0 Then

txtRecord.Text = "No items selected"

End If



Sub DetermineSelection(ByVal item As DataGridItem, ByRef count As Integer)

' Retrieve the SelectCheckBox CheckBox control from the

' specified item (row) in the DataGrid control.

Dim selection As CheckBox = CType(item.FindControl("editSavings"), CheckBox)

Dim n As String = " "

' If the item is selected, display the appropriate message and

' increment the count of selected items.

If Not selection Is Nothing Then

If selection.Checked Then

txtRecord.Text += item.Cells(2).Text

txtRecord.Text += item.Cells(3).Text

txtRecord.Text += item.Cells(4).Text

txtRecord.Text += item.Cells(5).Text

txtRecord.Text += item.Cells(6).Text

txtRecord.Text += item.Cells(7).Text

txtRecord.Text += item.Cells(8).Text

count = count + 1

End If

End If

End Sub

Ribeyed
05-09-2007, 12:12 PM
Hi,
create another table in your dataSet and read the repeater values into your new data table then databind that to your new repeater.

macker
05-09-2007, 12:15 PM
More Details Please?????

Thanks

Ribeyed
05-09-2007, 03:09 PM
Hi,
not tested this code but you should get the idea.


Dim objDataset As New System.Data.DataSet("ENVELOPE")
Dim DataTable As DataTable
objDataset.Tables.Add(New System.Data.DataTable("TempTable"))
Dim item As DataGridItem
Dim DataColumn As DataColumn
Dim DataRow As DataRow
DataTable = objDataset.Tables("TempTable")
DataColumn = New DataColumn("CatID")
DataTable.Columns.Add(DataColumn)
DataColumn = New DataColumn("depositType")
DataTable.Columns.Add(DataColumn)
DataColumn = New DataColumn("minToOpen")
DataTable.Columns.Add(DataColumn)
'Add a column for each ........

For Each item In Me.CommGridSavingRates.items

DetermineSelection(item, count)

Next

'in DetermineSelection add this code to your if statement:
If selection.Checked Then
DataRow = objDataset.Tables("TempTable").NewRow()
DataRow("CatID") = item.Cells(2).Text
DataRow("depositType") = item.Cells(3).Text
DatRow("minToOpen") = item.Cells(4).Text
'and so on..........
End If

'now all you have to do is databind the new table to your new datagrid.

macker
05-09-2007, 04:39 PM
What would be the code for the fill command to fill the new gridview??

Before it was all sql, now i can't figure out how to put this new dataset, into the gridview, the connection is no longer needed. It is a dataset, not a table. It is really screwing me up. I know it is one or two lines of code, I just can't figure out how to bind that table back to the new gridview.

Thanks again for all your help

Ribeyed
05-09-2007, 04:44 PM
Hi,
sure no problem. Didn't see where in your code you where retrieving the data to populate the first datagrid.

Add your other datagrid to your page then in your code behind and after your for loop just add these lines:


Datagrid2.DataSource = objDataset.Tables("TempTable")
Datagrid2.DataBind()

Then just add the same formatting and data columns as your first datagrid.

macker
05-10-2007, 10:18 AM
Well, I think it is working now, however, when I run it, nothing comes up in the new dg. The only thing that comes up is the header row.

Thank you for all the help, thusfar. I do appreciate it very much.

Here is the updated code:

coming in the next two posts::: It gave me an error, and said the max num of characters is 10,000........

macker
05-10-2007, 10:33 AM
Markup Part 1:::::::::::::::

<html>
<head id="Head1" runat="server">
<title>Edit Current Rates</title>

</head>
<body>
<form id="form1" runat="server">

<Table cellSpacing=1 cellPadding=5 border=0 style="" align="center" id="maintable">
<TBODY>
<TR>
<TD colSpan=10 style="font-family:Arial, helvetica; text-align:center">
<IMG src="slice/home_01.gif" border=0 />&nbsp;<br />
Edit Rates</td>
</tr>
<!-- Column Headers-->
<TR>
</TR>
</tbody>
</table>
<!-- Row Header-->
<table style="font-size:.8em">
<tr>
<td style="width: 75px; vertical-align:top; height: 63px;">
<FONT face=arial,helvetica,verdana size=-1><B>Savings</B></FONT>
</td>
<td style="width: 940px">
<!--<FONT face=arial,helvetica size=-1>--><asp: DataGrid ID="CommGridSavingRates" runat="server" style="text-align:center; word-break:keep-all" AutoGenerateColumns="False" TabIndex="9" CellPadding="4" GridLines="None" ForeColor="#333333" ><FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" />
<SelectedItemStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<AlternatingItemStyle BackColor="White" ForeColor="#284775" />
<ItemStyle BackColor="#F7F6F3" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:BoundColumn HeaderText="catID" Visible="False"></asp:BoundColumn>
<asp:BoundColumn DataField="catID" HeaderText="ID" SortExpression="catID"
Visible="False">
<ItemStyle HorizontalAlign="Right" />
</asp:BoundColumn>
<asp:BoundColumn DataField="depositType" HeaderText="Type of Deposit" SortExpression="Type of Deposit">
</asp:BoundColumn>
<asp:BoundColumn DataField="minToOpen" HeaderText="Minimum Amount to Open Account"></asp:BoundColumn>
<asp:BoundColumn DataField="maturity" HeaderText="Maturity"></asp:BoundColumn>
<asp:BoundColumn DataField="minBalanceToEarn" HeaderText="Minimum Balance to Earn APY">
</asp:BoundColumn>
<asp:BoundColumn DataField="interestRate" HeaderText="Interest Rate %"></asp:BoundColumn>
<asp:BoundColumn DataField="APY" HeaderText="Annual Percentage Yield % (APY)" ></asp:BoundColumn>
<asp:boundColumn DataField="compFreq" HeaderText="Compounding Frequency"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Edit Selection" HeaderStyle-HorizontalAlign="center">
<ItemTemplate>
<asp:CheckBox id="editSavings" runat="server" enableviewstate="true" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<EditItemStyle BackColor="#999999" />
</asp: DataGrid>
<!-- </FONT>-->

<FONT face=arial,helvetica size=-2><div style="text-align:right">Rates may change after account is opened.</div></FONT>
</td>
</tr>
<tr>
<td style="width: 75px; vertical-align:top"><FONT face=arial,helvetica,verdana size=-1><B>Interest
Bearing
Checking</B> </FONT>
</td>
<td style="width: 940px">

<asp: DataGrid ID="commgridChecking" runat="server" style="text-align:center" AutoGenerateColumns="False" TabIndex="9" CellPadding="4" GridLines="None" ForeColor="#333333">
<FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" /><SelectedItemStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<AlternatingItemStyle BackColor="White" ForeColor="#284775" />
<ItemStyle BackColor="#F7F6F3" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:BoundColumn HeaderText="catID" Visible="False"></asp:BoundColumn>
<asp:BoundColumn DataField="catID" HeaderText="ID" SortExpression="catID" Visible="False">
<ItemStyle HorizontalAlign="Right" />
</asp:BoundColumn>
<asp:BoundColumn DataField="depositType" HeaderText="Type of Deposit" SortExpression="Type of Deposit">
</asp:BoundColumn>
<asp:BoundColumn DataField="minToOpen" HeaderText="Minimum Amount to Open Account"></asp:BoundColumn>
<asp:BoundColumn DataField="maturity" HeaderText="Maturity"></asp:BoundColumn>
<asp:BoundColumn DataField="minBalanceToEarn" HeaderText="Minimum Balance to Earn APY">
</asp:BoundColumn>
<asp:BoundColumn DataField="interestRate" HeaderText="Interest Rate %"></asp:BoundColumn>
<asp:BoundColumn DataField="APY" HeaderText="Annual Percentage Yield % (APY)" ></asp:BoundColumn>
<asp:boundColumn DataField="compFreq" HeaderText="Compounding Frequency"></asp:BoundColumn>

<asp:TemplateColumn HeaderText="Edit Selection" HeaderStyle-HorizontalAlign="center">
<ItemTemplate>
<asp:CheckBox id="editChecking" runat="server" />
</ItemTemplate>
</asp:TemplateColumn>

</Columns>
<EditItemStyle BackColor="#999999" />
</asp: DataGrid>

<FONT face=arial,helvetica size=-2><div style="text-align:right">Rates may change after account is opened.</div></FONT>
</td>
</tr>
<tr>
<td style="width: 75px; vertical-align:top">
<FONT face=arial,helvetica,verdana size=-1><B>Certificates
of
Deposit</B> </FONT>
</td>

macker
05-10-2007, 10:35 AM
Markup Part 2::::::::::

<td style="width: 940px">

<asp: DataGrid ID="commgridCod" runat="server" style="text-align:center" AutoGenerateColumns="False" TabIndex="9" CellPadding="4" GridLines="None" ForeColor="#333333">
<FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" /><SelectedItemStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<AlternatingItemStyle BackColor="White" ForeColor="#284775" />
<ItemStyle BackColor="#F7F6F3" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:BoundColumn HeaderText="catID" Visible="False"></asp:BoundColumn>
<asp:BoundColumn DataField="catID" HeaderText="ID" SortExpression="catID" Visible="False">
<ItemStyle HorizontalAlign="Right" />
</asp:BoundColumn>
<asp:BoundColumn DataField="depositType" HeaderText="Type of Deposit" SortExpression="Type of Deposit">
</asp:BoundColumn>
<asp:BoundColumn DataField="minToOpen" HeaderText="Minimum Amount to Open Account"></asp:BoundColumn>
<asp:BoundColumn DataField="maturity" HeaderText="Maturity"></asp:BoundColumn>
<asp:BoundColumn DataField="minBalanceToEarn" HeaderText="Minimum Balance to Earn APY">
</asp:BoundColumn>
<asp:BoundColumn DataField="interestRate" HeaderText="Interest Rate %"></asp:BoundColumn>
<asp:BoundColumn DataField="APY" HeaderText="Annual Percentage Yield % (APY)" ></asp:BoundColumn>
<asp:boundColumn DataField="compFreq" HeaderText="Compounding Frequency"></asp:BoundColumn>

<asp:TemplateColumn HeaderText="Edit Selection" HeaderStyle-HorizontalAlign="center">
<ItemTemplate>
<asp:CheckBox id="editCod" runat="server" />
</ItemTemplate>
</asp:TemplateColumn>

</Columns>
<EditItemStyle BackColor="#999999" />
</asp: DataGrid>
<FONT face=arial,helvetica size=-2><div style="text-align:right">IRA Certificates must be for 12 months or more&nbsp;
</div></FONT>
</td>
</tr>

<tr><td colspan="2">
<div style="text-align:right; vertical-align:top"><asp:Button ID="btnEditRates" runat="server" Text="Edit Selected Records" /></div>
<BR /><FONT face=arial,helvetica>
<DIV class=banner><B>APY:</B> Annual Percentage Yield.<BR>Some accounts have minimum balance requirements to avoid fees, fees may reduce earning.
<br />Request further information by calling <B>314-984-8300.</B><br />
Rates effective 03-30-2007<B> <BR>Substantial penalty for early withdrawal may
apply.</B>
</DIV><br /></FONT>
</td></tr>
</table> &nbsp;
&nbsp;
&nbsp;&nbsp;
<asp: DataGrid ID="gridEdit" runat="server" style="text-align:center; font-size:.8em" AutoGenerateColumns="False" TabIndex="9" CellPadding="4" GridLines="None" ForeColor="#333333">
<FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" />
<EditItemStyle BackColor="#999999" />
<SelectedItemStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<AlternatingItemStyle BackColor="White" ForeColor="#284775" />
<ItemStyle BackColor="#F7F6F3" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:BoundColumn HeaderText="catID" Visible="False"></asp:BoundColumn>
<asp:BoundColumn DataField="catID" HeaderText="ID" SortExpression="catID"
Visible="False">
<ItemStyle HorizontalAlign="Right" />
</asp:BoundColumn>


<asp:TemplateColumn HeaderText="Type of Deposit">
<ItemTemplate>
<asp:TextBox id=txtDepositType runat="server" Width="109px" Text='<%# DataBinder.Eval(Container, "DataItem.depositType") %>'>
</asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtNewDepositType" runat="server" Width="109px"></asp:TextBox>
</FooterTemplate>
</asp:TemplateColumn>


<asp:TemplateColumn HeaderText="Minimum Amount to Open Account">
<ItemTemplate>
<asp:TextBox id=txtMinToOpen runat="server" Width="109px" Text='<%# DataBinder.Eval(Container, "DataItem.minToOpen") %>'>
</asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtNewMinToOpen" runat="server" Width="109px"></asp:TextBox>
</FooterTemplate>
</asp:TemplateColumn>


<asp:TemplateColumn HeaderText="Maturity">
<ItemTemplate>
<asp:TextBox id=txtMaturity runat="server" Width="109px" Text='<%# DataBinder.Eval(Container, "DataItem.maturity") %>'>
</asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtNewMaturity" runat="server" Width="109px"></asp:TextBox>
</FooterTemplate>
</asp:TemplateColumn>


<asp:TemplateColumn HeaderText="Minimum Balance to Earn APY">
<ItemTemplate>
<asp:TextBox id=txtMinBalanceToEarn runat="server" Width="109px" Text='<%# DataBinder.Eval(Container, "DataItem.minBalanceToEarn") %>'>
</asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtNewMinBalanceToEarn" runat="server" Width="109px"></asp:TextBox>
</FooterTemplate>
</asp:TemplateColumn>



<asp:TemplateColumn HeaderText="Interest Rate %">
<ItemTemplate>
<asp:TextBox id=txtInterestRate runat="server" Width="109px" Text='<%# DataBinder.Eval(Container, "DataItem.interestRate") %>'>
</asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtNewInterestRate" runat="server" Width="109px"></asp:TextBox>
</FooterTemplate>
</asp:TemplateColumn>


<asp:TemplateColumn HeaderText="Annual Percentage Yield % (APY)">
<ItemTemplate>
<asp:TextBox id=txtAPY runat="server" Width="109px" Text='<%# DataBinder.Eval(Container, "DataItem.apy") %>'>
</asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtNewAPY" runat="server" Width="109px"></asp:TextBox>
</FooterTemplate>
</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="Compounding Frequency">
<ItemTemplate>
<asp:TextBox id=txtCompFreq runat="server" Width="109px" Text='<%# DataBinder.Eval(Container, "DataItem.compFreq") %>'>
</asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtNewCompFreq" runat="server" Width="109px"></asp:TextBox>
</FooterTemplate>
</asp:TemplateColumn>



<asp:TemplateColumn HeaderText="Edit Selection">
<ItemTemplate>
<asp:button ID="commit" Text="Commit Changes" runat="server" />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
</asp:TemplateColumn>
</Columns>
</asp: DataGrid>
</form>

</body>
</html>

macker
05-10-2007, 10:36 AM
VB Code::::

Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Web.UI.WebControls

'Option Explicit On
'Option Strict On

Public Class EditCurrentRates
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load
If Not Page.IsPostBack Then
gridEdit.Visible = False
Dim myConnection As Data.SqlClient.SqlConnection
Dim myCommand As Data.SqlClient.SqlDataAdapter

myConnection = New Data.SqlClient.SqlConnection("server=SNSQLDEV01;" _
& "database=StifelBank;Trusted_Connection=Yes")

myCommand = New Data.SqlClient.SqlDataAdapter("SELECT * FROM rate_Details WHERE catID = 3", _
myConnection)

Dim ds As Data.DataSet = New Data.DataSet()
myCommand.Fill(ds)

CommGridSavingRates.DataSource = ds
CommGridSavingRates.DataBind()

Dim myConnection2 As Data.SqlClient.SqlConnection
Dim myCommand2 As Data.SqlClient.SqlDataAdapter

myConnection2 = New Data.SqlClient.SqlConnection("server=SNSQLDEV01;" _
& "database=StifelBank;Trusted_Connection=Yes")

myCommand2 = New Data.SqlClient.SqlDataAdapter("SELECT * FROM rate_Details WHERE catID = 2", _
myConnection2)

Dim ds2 As Data.DataSet = New Data.DataSet()
myCommand2.Fill(ds2)

commgridChecking.DataSource = ds2
commgridChecking.DataBind()

Dim myConnection3 As Data.SqlClient.SqlConnection
Dim myCommand3 As Data.SqlClient.SqlDataAdapter

myConnection3 = New Data.SqlClient.SqlConnection("server=SNSQLDEV01;" _
& "database=StifelBank;Trusted_Connection=Yes")

myCommand3 = New Data.SqlClient.SqlDataAdapter("SELECT * FROM rate_Details WHERE catID = 1", _
myConnection3)

Dim ds3 As Data.DataSet = New Data.DataSet()
myCommand3.Fill(ds3)

commgridCod.DataSource = ds3
commgridCod.DataBind()
End If
End Sub
Private Sub EditRates_onClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnEditRates.Click
Checker()
gridEdit.Visible = True
End Sub
Private Sub Checker()
Dim count As Integer = 0
Dim objDataset As New System.Data.DataSet("ENVELOPE")
Dim DataTable As Data.DataTable
objDataset.Tables.Add(New System.Data.DataTable("TempTable"))
Dim item As DataGridItem
Dim DataColumn As Data.DataColumn
Dim DataRow As Data.DataRow
DataTable = objDataset.Tables("TempTable")
DataColumn = New Data.DataColumn("CatID")
DataTable.Columns.Add(DataColumn)
DataColumn = New Data.DataColumn("depositType")
DataTable.Columns.Add(DataColumn)
DataColumn = New Data.DataColumn("minToOpen")
DataTable.Columns.Add(DataColumn)
DataColumn = New Data.DataColumn("maturity")
DataTable.Columns.Add(DataColumn)
DataColumn = New Data.DataColumn("minBalanceToEarn")
DataTable.Columns.Add(DataColumn)
DataColumn = New Data.DataColumn("interestRate")
DataTable.Columns.Add(DataColumn)
DataColumn = New Data.DataColumn("apy")
DataTable.Columns.Add(DataColumn)
DataColumn = New Data.DataColumn("compfreq")
DataTable.Columns.Add(DataColumn)

Dim selection As CheckBox
For Each item In CommGridSavingRates.Items
selection = item.FindControl("editSavings")
If Not selection Is Nothing Then
If selection.Checked Then
DataRow = objDataset.Tables("TempTable").NewRow()
DataRow("catID") = item.Cells(1).Text
DataRow("depositType") = item.Cells(2).Text
DataRow("minToOpen") = item.Cells(3).Text
DataRow("maturity") = item.Cells(4).Text
DataRow("minBalanceToEarn") = item.Cells(5).Text
DataRow("interestRate") = item.Cells(6).Text
DataRow("apy") = item.Cells(7).Text
DataRow("compfreq") = item.Cells(8).Text
End If
End If
Next

gridEdit.DataSource = objDataset.Tables("TempTable")
gridEdit.DataBind()

' If no items are selected, display the appropriate message.
If count = 0 Then
' txtRecord.Text = "No items selected"
End If
End Sub
End Class

Ribeyed
05-10-2007, 11:28 AM
Hi,
ok still at work and i wrote that code at home. I missed a couple of lines of code out, sorry :)

Change this line:

DataRow= objDataset.Tables("TempTable").NewRow()

to

DataTable = objDataset.Tables("TempTable")
DataRow = DataTable.NewRow()

Then after this line:
DataRow("compfreq") = item.Cells(8).Text
add this:
DataTable.Add(DataRow)

Forgot to add the new datarow to the new table.

macker
05-10-2007, 11:47 AM
I don't know if that worked or not, seems like it should.
VS does not like the last line below. "DataTable.Add(DataRow)"

It gives me an error of "Add is not a member of System.Data.DataTable"

Any ideas?

Again, thank you so much for the help.
I have stepped through it, and it does pick up on the ones that are checked, and steps through the loop like it is adding the rows, however, when the dg is displayed, it is empty like before. The only thing that shows is the header.


Then after this line:
DataRow("compfreq") = item.Cells(8).Text
add this:
DataTable.Add(DataRow)

Ribeyed
05-10-2007, 12:04 PM
Hi,
ok still at work and i wrote that code at home. I missed a couple of lines of code out, sorry :)

Change this line:

DataRow= objDataset.Tables("TempTable").NewRow()

to

DataTable = objDataset.Tables("TempTable")
DataRow = DataTable.NewRow()

Then after this line:
DataRow("compfreq") = item.Cells(8).Text
add this:
DataTable.Rows.Add(DataRow)

Forgot to add the new datarow to the new table.

macker
05-10-2007, 12:43 PM
VICTORY!!!! (now i just have to get the 'commit changes' button to work)

THANK YOU SO MUCH, MAN, I CANNOT THANK YOU ENOUGH!!!

I wish I could help you back, but it looks like you pretty much have it figured out!!!

If you ever have an automobile question, let me know.
You can also let me know at my website: http://ezonlinemechanic.net

Thanks again, I will be sure to spread the word of how helpful and kind you have been.

thank you

Ribeyed
05-10-2007, 02:17 PM
lol thx, no worries glad i could help.
Just to answer your question about the DataSet. A dataset is a disconnect representation of a relational database so you can have multiple tables with relationships in the one dataset.
Once you get going with the dataset you'll be able to manipulate your data without having to go back yo your server time after time.

good luck!