chrispaul8676 0 Light Poster

hi, there, i am trying to work out selecting rows in gridview using checkbox and button submit after rows are selected. Please guide me. i have time till 11am today. the errors:

dsnews- unused local variable
CheckBox1-String constants must end with double quote
                 -Not declared

IsChecked- not declared

Dropdownlist code

<asp:GridView ID="GridView1" AutoGenerateColumns="False" AutoGenerateEditButton="True"  runat="server" 
            AllowPaging="True" >

            <Columns>
        <asp:TemplateField HeaderText="Check"> 



    <ItemTemplate> 

        <asp:CheckBox ID="CheckBox1" runat="server"  Text="check"

            onclick = "Check_Click(this)"/> 

    </ItemTemplate> 

</asp:TemplateField> 






        <asp:BoundField ItemStyle-Width = "150px"  ReadOnly="true" SortExpression="CusID"

    DataField = "CusID" HeaderText = "Customer ID" > 

<ItemStyle Width="150px"></ItemStyle>
            </asp:BoundField>

<asp:BoundField ItemStyle-Width = "150px" 

    DataField = "CusFName" HeaderText = "First Name"> 

<ItemStyle Width="150px"></ItemStyle>
            </asp:BoundField>

<asp:BoundField ItemStyle-Width = "150px" 

    DataField = "CusLName" HeaderText = "Last Name"> 

<ItemStyle Width="150px"></ItemStyle>
            </asp:BoundField>

<asp:BoundField ItemStyle-Width = "150px" 

    DataField = "Address" HeaderText = "Address"> 
<ItemStyle Width="150px"></ItemStyle>
            </asp:BoundField>
<asp:BoundField ItemStyle-Width = "150px" 

    DataField = "City" HeaderText = "City"> 
<ItemStyle Width="150px"></ItemStyle>
            </asp:BoundField>
    <asp:BoundField ItemStyle-Width = "150px" 

    DataField = "State" HeaderText = "State">

<ItemStyle Width="150px"></ItemStyle>
            </asp:BoundField>

    <asp:BoundField ItemStyle-Width = "150px" 

    DataField = "HP_Num" HeaderText = "HP_Num">

<ItemStyle Width="150px"></ItemStyle>
            </asp:BoundField>

    <asp:BoundField ItemStyle-Width = "150px" 

    DataField = "receiver" HeaderText = "Receiver Name">
<ItemStyle Width="150px"></ItemStyle>
            </asp:BoundField>
    <asp:BoundField ItemStyle-Width = "150px" 

    DataField = "Address1" HeaderText = "Address">
<ItemStyle Width="150px"></ItemStyle>
            </asp:BoundField>
    <asp:BoundField ItemStyle-Width = "150px" 

    DataField = "Poscode" HeaderText = "Poscode">
<ItemStyle Width="150px"></ItemStyle>
            </asp:BoundField>
    <asp:BoundField ItemStyle-Width = "150px" 

    DataField = "City1" HeaderText = "City">

<ItemStyle Width="150px"></ItemStyle>
            </asp:BoundField>

    <asp:BoundField ItemStyle-Width = "150px" 

    DataField = "State1" HeaderText = "State">
<ItemStyle Width="150px"></ItemStyle>
            </asp:BoundField>
    <asp:BoundField ItemStyle-Width = "150px" 

    DataField = "Contact_Num" HeaderText = "Contact Number">





<ItemStyle Width="150px"></ItemStyle>
            </asp:BoundField>





        </Columns>
    </asp:GridView>

    </form>
    <asp:Button ID="Button1" runat="server" Text="Button" />

VB behind code

Imports System.Data.Sql
Imports System.Data.SqlClient
Imports System.Data
Imports System.Web

Partial Class Assign
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        'Dim objbllNews As New BLL.News
        If (IsPostBack = False) Then
            Dim dsNews As DataSet
            Try
                Dim dsData As DataSet = New DataSet()
                Dim CMD As SqlCommand

                'Change the following connection string depends on your sql server ‘authentication
                Dim con As SqlConnection = New SqlConnection("Data Source=localhost;Initial Catalog=Northwind;TimeOut=60;User ID=sa;Password=;")
                CMD = New SqlCommand("SELECT * FROM [Employees]", con)

                Dim adpt As New SqlDataAdapter(CMD)
                adpt.Fill(dsData)

                GridView1.DataSource = dsData
                GridView1.DataBind()
            Catch ex As Exception
                Throw ex
            End Try
        End If


    End Sub

    Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound

        If e.Row.RowType = DataControlRowType.DataRow Then '1
Dim Chk As CheckBox = e.Row.FindControl("CheckBox1″) 
            Page.ClientScript.RegisterStartupScript(Me.GetType(), "MyScript", " function HighlightSelected(colorcheckboxselected, RowState) { if (colorcheckboxselected.checked) colorcheckboxselected.parentElement.parentElement.style.backgroundColor=’#FFAA63′; else { if (RowState==’0′) colorcheckboxselected.parentElement.parentElement.style.backgroundColor=’white’; else colorcheckboxselected.parentElement.parentElement.style.backgroundColor=’#D6E3F7′; } }", True) '3
            CheckBox1.Attributes.Add("onclick", "HighlightSelected(this,’" + Convert.ToString(e.Row.RowState) + "‘ );") '4
        End If '5

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        If IsPostBack = True Then
            Dim str As StringBuilder = New StringBuilder()
            ' Select the checkboxes from the GridView control
            Dim i As Integer
For i = 0 To GridView1.Rows.Count – 1 Step i + 1
                Dim row As GridViewRow = DataGV.Rows(i)
Dim isChecked As Boolean = (CType(row.FindControl(”CheckBox1″), CheckBox)).Checked
                If (isChecked) Then
                    str.Append(GridView1.Rows(i).Cells(2).Text)
                End If
            Next
            ' prints out the result
            Response.Write(str.ToString())
        End If

    End Sub
End Class