[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

get the Value of textbox in gridview

Posted on 2009-12-18
40
Medium Priority
?
1,618 Views
Last Modified: 2012-05-08
Hi,

I have about 5 Product Gridviews, where the gridviews are populated based on product Category.

In these gridviews, i have " +" sign.Whne the user clicks on it, the product gets added to "Request Gridview" like the shopping cart. The user then, enters the quantity he needs.

Now with the other information on th aspx page like shipping information( all textboxes on aspx page), the page gets submitted.

So what i basically do is, enter the shipping information to database and then enters request items to database.

But the problem is i'm not getting the textbox value of the quantity from the Gridview.

I'm not using RowUpdating event on that RequestCart to get that value.

Please help me get the Quantity textbox value.
BTW, i add the quantity textbox of the requestCart gridview , programatically.

I have pasted the code below.

Thanks for looking


Private Function CallRequestCartInsert(ByVal RequestId As Guid) As Boolean


        For Each gr As GridViewRow In requestCart.Rows

            Dim Quantity As String = DirectCast(gr.FindControl("txtQuantity"), TextBox).Text

            Response.Write(Quantity)
            Response.End()


            If Not (Quantity = String.Empty) Then
                Dim gridRow As GridViewRow = gr
                Dim RequestItemId As Guid = System.Guid.NewGuid

                '===Set the ProductId andBrochureId and quantity,in the currently selected row.
                Dim BrochureId As String = gridRow.Cells(3).Text.ToString
                Dim ProductId As String = gridRow.Cells(4).Text.ToString
              'Insert Statement


             
            End If
        Next

    End Function

Open in new window

0
Comment
Question by:SaraDob
  • 21
  • 14
  • 3
38 Comments
 
LVL 15

Expert Comment

by:rajeeshmca
ID: 26081706
Can u post the aspx page
0
 
LVL 1

Author Comment

by:SaraDob
ID: 26081872
Here come the apx page with information on only request cart and one of the product brochure cart.
I have also added the way i add txtbox programatically
 
0
 
LVL 1

Author Comment

by:SaraDob
ID: 26081920
Opps i don't see the attachement..I posting it again..sorry if it is a repeatation
Protected Sub RequestCart_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs)


        If e.Row.RowType = DataControlRowType.DataRow Then

            Dim whereToAdd As Control = DirectCast(e.Row.FindControl("phData"), PlaceHolder)
            Dim dummy As Control = whereToAdd.NamingContainer
            Dim tb As New TextBox()
            tb.ID = "txtQuantity"
            tb.Columns = "10"
            whereToAdd.Controls.Add(tb)
            tb.Attributes.Add("onchange", "javascript:onChange=checkNum(this);")
            tb.Text = ""

            '    Dim tt As TextBox = DirectCast(whereToAdd.FindControl("heho"), TextBox)
        End If

        UpdatePanelRequestCart.Update()

    End Sub
<table align="center"><tr>
<td class ="th"  align="center">Request Cart
       <asp:GridView ID="requestCart" runat="server"
         cellpadding="5" font-size="8pt"
         headerstyle-backcolor="gray"
         headerstyle-forecolor="khaki"
         rowstyle-backcolor="ivory"
        EmptyDataText ="Select  Request Items into the Cart"
         rowstyle-verticalalign="top" onRowCommand="Requestcart_UpateRequestCart" onRowCreated="RequestCart_RowCreated">
         <Columns>
         
        <asp:buttonfield HeaderText="Remove" text=" - " buttontype="button" commandname="RemoveFromCart"/>   
         <asp:TemplateField HeaderText="Quantity">
            <ItemTemplate>
                <!-- Dynamically adding a TextBox here causes problems -->
                <asp:PlaceHolder ID="phData" runat="server" />
            </ItemTemplate>
        </asp:TemplateField>
                       </Columns>
       </asp:GridView>
        
   </td></tr>
</table>

  <asp:GridView ID="GrdMSeries"  CssClass="tabulardata" 
        runat="server" AllowSorting="True" AutoGenerateColumns="False" 
       emptydatatext="No Brochures available." DataSourceID="SQLMSeries" onRowCreated="setButtonStyle"
      onRowCommand="updateCart">
      <Columns>
        <asp:BoundField DataField="ProductId"/>
            <asp:BoundField DataField="BrochureId"/>
            <asp:BoundField DataField="ProductCategory" />
           <asp:BoundField DataField="BrochureName" HeaderText="Brochure Name" SortExpression="BrochureName" />
           <asp:BoundField DataField="Revision" HeaderText="Revision" SortExpression="Revision" />
           <asp:buttonfield HeaderText="Add" text=" + "  buttontype="button" commandname="AddToCart"/>
    </Columns>
       </asp:GridView>

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:SaraDob
ID: 26082075
Hellloo!!!! anyone ? knock knock..
0
 
LVL 15

Expert Comment

by:rajeeshmca
ID: 26082407
HI

In this line we are fetching from the requestCart grid and not from the rows

so change
For Each gr As GridViewRow In requestCart.Rows
to
For Each gr As GridViewRow In requestCart

0
 
LVL 15

Expert Comment

by:rajeeshmca
ID: 26082423
what does it say at

Dim Quantity As String = DirectCast(gr.FindControl("txtQuantity"), TextBox).Text


any error ?
0
 
LVL 1

Author Comment

by:SaraDob
ID: 26082622
For Each gr As GridViewRow In requestCart
 Gives an error"Expresiion of type(syste.web.ui.Webcontrols) is of collection type..
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 26106699
You need to use FindControl from the row:

For Each gr As GridViewRow In requestCart.Rows
   Dim txtQuantity As TextBox = TryCast(gr.FindControl("txtQuantity"), TextBox)
   If txtQuanity IsNot Nothing Then
   End If
Next gr
0
 
LVL 1

Author Comment

by:SaraDob
ID: 26107715
Thanks for the replt TheLearnedOne,
I kind of see the problem.I have a placeholder inside the ItemTemplate in the gridview.So i had not mentioned the palceholder. now i put in this code, but still not able to retrieve the value of the textbox...
can you please please help me!

For Each gr As GridViewRow In requestCart.Rows

            '============================================
            If gr.RowType = DataControlRowType.DataRow Then

                Dim Holder1 As PlaceHolder = DirectCast(gr.FindControl("phData"), PlaceHolder)
                Dim Quantity As String = DirectCast(Holder1.FindControl("txtQuantity"), TextBox).Text
                Response.Write(Quantity)

Dim BrochureId As String = gr.Cells(3).Text.ToString()
                                        End If

        Next

Open in new window

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 26107886
Why do you need the PlaceHolder control?  Those are generally used for dynamic controls.  If you are using dynamic controls, added to a PlaceHolder, then they need to be recreated for every page request, and not just the initial page load.
0
 
LVL 1

Author Comment

by:SaraDob
ID: 26108013
I'm having the placeholder In Item template of the gridview to indicate , where the textbox ia added dynamically.
Am i Wrong.
 
Thanks for staying on this... i need to Desp complete it today.. :(
 

Protected Sub RequestCart_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs)


        If e.Row.RowType = DataControlRowType.DataRow Then

            Dim whereToAdd As Control = DirectCast(e.Row.FindControl("phData"), PlaceHolder)
            Dim dummy As Control = whereToAdd.NamingContainer
            Dim tb As New TextBox()
            tb.ID = "txtQuantity"
            tb.Columns = "10"
            whereToAdd.Controls.Add(tb)
            tb.Attributes.Add("onchange", "javascript:onChange=checkNum(this);")
            tb.Text = ""
            tb.EnableViewState = True

            '    Dim tt As TextBox = DirectCast(whereToAdd.FindControl("heho"), TextBox)
        End If

        ' UpdatePanelRequestCart.Update()

    End Sub

Open in new window

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 26108084
You don't need the PlaceHolder, and you should be able to use a statically defined TextBox.  It would make it easier to use FindControl.
0
 
LVL 1

Author Comment

by:SaraDob
ID: 26108174
Okay, I would use that. I put in the gridview itself...
Now still the value is Null. i think it is beacuse of the Postback.
Thia is My page_load function.In fact i'm attaching whole page now..
Please have a look and let me know, where me myself and dumbest me is wrong..
Please let me know...where am i going wrong...Please
0
 
LVL 1

Author Comment

by:SaraDob
ID: 26108182
Opps! Attachement din't come through  Here it is..
I know there are experts like you  to guide us.. Please don't mind the whole code...

Imports System.Net.Mail    '|||| required for Sending emails froms erver
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Web.Security '   |||||   Required Class for Authentication
Imports System.Data '   |||||   DB Accessing Import
Imports System.Text
Imports System.Data.SqlTypes
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Collections.Specialized
Partial Class DobleRepCorner_Literature_RequestLiterature
    Inherits System.Web.UI.Page
    Dim MyConn As SqlConnection = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("StrConn"))
    Dim Cart As DataTable
    Dim CartView As DataView
    
    Private Sub CheckSession()

        Dim objChkSessionId As String

        objChkSessionId = Session("SesUserId")

        If objChkSessionId = "" Then
            Session.Abandon()
            Response.Redirect("~/Login.aspx?Yoursession=expired")
        Else
            Dim SalesuserId As Guid = New Guid(Session("SesUserId").ToString())
        End If
    End Sub
    Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs) Handles Me.Load

        Response.BufferOutput = True
        Response.ExpiresAbsolute = DateTime.Now.AddDays(-1.0R)
        Response.Expires = 0
        Response.CacheControl = "no-cache"

        '====Check Session
        CheckSession()
        HttpContext.Current.Response.AppendHeader("Refresh", Convert.ToString(((HttpContext.Current.Session.Timeout * 60) - 10)) & "; Url=~/Login.aspx?Yoursession=expired")


        If Session("shoppingSession") Is Nothing Then
            Cart = New DataTable()

            Cart.Columns.Add(New DataColumn("BrochureName", GetType(String)))
            Cart.Columns.Add(New DataColumn("BrochureId", GetType(String)))
            Cart.Columns.Add(New DataColumn("ProductID", GetType(String)))

            Session("shoppingSession") = Cart

        Else


            Cart = DirectCast(Session("shoppingSession"), DataTable)
        End If

        CartView = New DataView(Cart)
        requestCart.DataSource = CartView


        requestCart.DataBind()
    End Sub
    '====Adding the Selected Items to the request cart
    Public Sub updateCart(ByVal src As [Object], ByVal e As GridViewCommandEventArgs)

        Dim dr As DataRow = Cart.NewRow()

        ' get the row index stored in the CommandArgument property 
        Dim index As Integer = Convert.ToInt32(e.CommandArgument)

        ' get the GridViewRow where the command is raised 
        Dim selectedRow As GridViewRow = DirectCast(e.CommandSource, GridView).Rows(index)

        ' for bound fields, values are stored in the Text property of Cells [ fieldIndex ] 

        Dim BrochureName As String = selectedRow.Cells(3).Text
        Dim BrochureId As String = selectedRow.Cells(1).Text
        Dim Productid As String = selectedRow.Cells(0).Text
        ' Dim MaintainOld As DataTable


        If e.CommandName = "AddToCart" Then

            dr(0) = BrochureName
            dr(1) = BrochureId
            dr(2) = Productid


            Cart.Rows.Add(dr)


        End If

        requestCart.DataSource = CartView

        requestCart.DataBind()
        ' UpdatePanelRequestCart.Update()

    End Sub
    '====Setting the button stle for request cart, when it is created
    Public Sub setButtonStyle(ByVal src As [Object], ByVal e As GridViewRowEventArgs)
        If e.Row.RowType = DataControlRowType.DataRow Then


            Dim cells As TableCellCollection = e.Row.Cells
            DirectCast(cells(5).Controls(0), Button).CssClass = "add"

        End If
    End Sub
    '====Sremoving the Item from the request Cart
    Public Sub Requestcart_UpateRequestCart(ByVal src As [Object], ByVal e As GridViewCommandEventArgs)


        ' get the row index stored in the CommandArgument property 
        Dim index As Integer = Convert.ToInt32(e.CommandArgument)

        ' get the GridViewRow where the command is raised 
        Dim selectedRow As GridViewRow = DirectCast(e.CommandSource, GridView).Rows(index)

        ' for bound fields, values are stored in the Text property of Cells [ fieldIndex ] 

        Dim brochurename As String = selectedRow.Cells(2).Text

        If e.CommandName = "RemoveFromCart" Then
            ' remove from Cart 


            CartView.RowFilter = "BrochureName='" & brochurename & "'"

            If CartView.Count > 0 Then

                CartView.Delete(0)

            End If
            CartView.RowFilter = ""
            '  requestCart.DataSource = Session("shoppingSession")
            requestCart.DataBind()

        End If
        'UpdatePanelRequestCart.Update()

    End Sub
    '====Adding a quantity textbox in requestBox
    Protected Sub RequestCart_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs)


        '  If e.Row.RowType = DataControlRowType.DataRow Then

        'Dim whereToAdd As Control = DirectCast(e.Row.FindControl("phData"), PlaceHolder)
        '  Dim dummy As Control = whereToAdd.NamingContainer
        ' Dim tb As New TextBox()
        ' tb.ID = "txtQuantity"
        ' tb.Columns = "10"
        ' whereToAdd.Controls.Add(tb)
        ' tb.Attributes.Add("onchange", "javascript:onChange=checkNum(this);")
        ' tb.Text = ""
        ' tb.EnableViewState = True

        '    Dim tt As TextBox = DirectCast(whereToAdd.FindControl("heho"), TextBox)
        ' End If

        ' UpdatePanelRequestCart.Update()

    End Sub
    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        Updatedatabase()
        ' SendMail()
    End Sub

    Public Sub Updatedatabase()
        'Insert The Name,Contact Details to LiteratureRequests\
        Dim SalesuserId As Guid = New Guid(Session("SesUserId").ToString())

        Dim ContactName As String = TxtName.Text.Trim()
        Dim CompanyName As String = TxtNameOfCompany.Text.Trim()
        Dim AddressLine1 As String = TxtShipToAddress1.Text.Trim()
        Dim AddressLine2 As String = TxtShipToAddress2.Text.Trim()
        Dim City As String = TxtCity.Text.Trim()
        Dim State As String = TxtState.Text.Trim()
        Dim Country As String = TxtCountry.Text.Trim()
        Dim ZipCode As String = TxtZipCode.Text.Trim()
        Dim Phone As String = txtPhone.Text.Trim()
        Dim Fax As String = TxtFax.Text.Trim()
        Dim ToDate As DateTime = DateTime.Now
        Dim Comments As String = TxtComments.Text.Trim()

        '======= Get The StateProvinceid
        '=================================
        Dim CmdCountrySearch As SqlCommand

        Dim CountryID As Guid
        '==='Get the Guid of the product Selected

        Try
            CmdCountrySearch = New SqlCommand(("Select StateProvinceId from StateProvince where CountryRegionName='" & Country & "'"), MyConn)

            Dim CountryIdReader As SqlDataReader
            If MyConn.State = ConnectionState.Closed Then
                MyConn.Open()
            End If

            If MyConn.State = ConnectionState.Open Then
                CountryIdReader = CmdCountrySearch.ExecuteReader
                While CountryIdReader.Read
                    CountryID = CountryIdReader.GetGuid(0)
                End While
                MyConn.Close()
            End If

            CountryIdReader.Close()
            CmdCountrySearch.Dispose()
        Catch ex As Exception
            lblMessage.Text = ex.Message
        End Try

        '=============================================================================
        '=====Generate BookingID and insert the Brochure name along with productis in ProductBrochure table
        Dim RequestId As Guid
        Dim CmdLiteratureRequest As SqlCommand
        Dim StrLiteratureInsert As String
        Dim Mydate As DateTime = DateTime.Now


        Try
            RequestId = System.Guid.NewGuid

            StrLiteratureInsert = "Insert into LiteratureRequests values (@RequestId,@SalesUserId,@CompanyName,@ContactName, @AddressLine1,@AddressLine2," _
                   & "@City,@State,@ZipCode,@ZipExt,@StateProvinceId,@RequestDate,@CompletionDate,@Status,@emailAddress,@Phone,@Fax,@Comments,@TrackingNumber,@ShippingDetails);"

            ' Initialize the SqlCommand with the new SQL string.

            CmdLiteratureRequest = New SqlCommand(StrLiteratureInsert, MyConn)

            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@RequestId", SqlDbType.UniqueIdentifier))
            CmdLiteratureRequest.Parameters("@RequestId").Value = New SqlGuid(RequestId)

            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@SalesUserId", SqlDbType.UniqueIdentifier))
            CmdLiteratureRequest.Parameters("@SalesUserId").Value = New SqlGuid(SalesuserId)

            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@CompanyName", SqlDbType.NVarChar, 50))
            If CompanyName = "" Then
                CmdLiteratureRequest.Parameters("@CompanyName").Value = DBNull.Value
            Else
                CmdLiteratureRequest.Parameters("@CompanyName").Value = CompanyName
            End If


            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@ContactName", SqlDbType.NVarChar, 50))
            If ContactName = "" Then
                CmdLiteratureRequest.Parameters("@ContactName").Value = DBNull.Value
            Else
                CmdLiteratureRequest.Parameters("@ContactName").Value = ContactName
            End If


            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@AddressLine1", SqlDbType.NVarChar, 80))
            CmdLiteratureRequest.Parameters("@AddressLine1").Value = AddressLine1

            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@AddressLine2", SqlDbType.NVarChar, 80))
            If AddressLine2 = "" Then
                CmdLiteratureRequest.Parameters("@AddressLine2").Value = DBNull.Value
            Else
                CmdLiteratureRequest.Parameters("@AddressLine2").Value = AddressLine2
            End If


            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@City", SqlDbType.NVarChar, 60))
            CmdLiteratureRequest.Parameters("@City").Value = City

            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@State", SqlDbType.NVarChar, 60))
            CmdLiteratureRequest.Parameters("@State").Value = State

            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@ZipCode", SqlDbType.NVarChar, 50))
            CmdLiteratureRequest.Parameters("@ZipCode").Value = ZipCode


            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@ZipExt", SqlDbType.NVarChar, 50))
            CmdLiteratureRequest.Parameters("@ZipExt").Value = ZipCode

            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@StateProvinceId", SqlDbType.UniqueIdentifier))
            CmdLiteratureRequest.Parameters("@StateProvinceId").Value = CountryID

            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@RequestDate", SqlDbType.DateTime))
            CmdLiteratureRequest.Parameters("@RequestDate").Value = ToDate

            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@CompletionDate", SqlDbType.DateTime))
            CmdLiteratureRequest.Parameters("@CompletionDate").Value = DBNull.Value


            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@Status", SqlDbType.NVarChar, 15))
            CmdLiteratureRequest.Parameters("@Status").Value = "New"

            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@emailAddress", SqlDbType.NVarChar, 100))
            CmdLiteratureRequest.Parameters("@emailAddress").Value = DBNull.Value

            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@Phone", SqlDbType.NVarChar, 15))
            If Phone = "" Then
                CmdLiteratureRequest.Parameters("@Phone").Value = DBNull.Value
            Else
                CmdLiteratureRequest.Parameters("@Phone").Value = Phone
            End If


            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@Fax", SqlDbType.NVarChar, 15))
            If Fax = "" Then
                CmdLiteratureRequest.Parameters("@Fax").Value = DBNull.Value
            Else
                CmdLiteratureRequest.Parameters("@Fax").Value = Fax
            End If

            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@Comments", SqlDbType.NVarChar, 20000))
            If Comments = "" Then
                CmdLiteratureRequest.Parameters("@Comments").Value = DBNull.Value
            Else
                CmdLiteratureRequest.Parameters("@Comments").Value = Comments
            End If

            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@TrackingNumber", SqlDbType.NVarChar, 50))
            CmdLiteratureRequest.Parameters("@TrackingNumber").Value = DBNull.Value

            CmdLiteratureRequest.Parameters.Add(New SqlParameter("@ShippingDetails", SqlDbType.NVarChar, -1))
            CmdLiteratureRequest.Parameters("@ShippingDetails").Value = DBNull.Value

            If MyConn.State = ConnectionState.Closed Then
                MyConn.Open()
            End If

            If MyConn.State = ConnectionState.Open Then
                'CmdLiteratureRequest.ExecuteNonQuery()
                MyConn.Close()
            End If
            CmdLiteratureRequest = Nothing
            StrLiteratureInsert = Nothing

            '=======================Call the sub Which Inserts request cart items

            CallRequestCartInsert(RequestId)


            '==============Set the input textboxes to null
            '  TxtCity.Text = ""
            '  TxtCountry.Text = ""
            '  TxtFax.Text = ""
            '  TxtName.Text = ""
            '  TxtNameOfCompany.Text = ""
            '  txtPhone.Text = ""
            ' TxtShipToAddress1.Text = ""
            ' TxtShipToAddress2.Text = ""
            ' TxtState.Text = ""
            ' TxtZipCode.Text = ""
            ' TxtComments.Text = ""

            lblMessage.Text = "Brochure Added Successfully"
        Catch ex As Exception
            lblMessage.Text = ex.Message
        End Try

        '====Try jquery to confirm from the user the selection
        '===Submit.
    End Sub

    Private Function CallRequestCartInsert(ByVal RequestId As Guid) As Boolean

        ' Dim mpContentPlaceHolder As ContentPlaceHolder
        'mpContentPlaceHolder = CType(Master.FindControl("RequestContent"), ContentPlaceHolder)


        '  If Not mpContentPlaceHolder Is Nothing Then


        For Each gr As GridViewRow In requestCart.Rows

            '============================================
            If gr.RowType = DataControlRowType.DataRow Then

                ' Dim Holder1 As PlaceHolder = DirectCast(gr.FindControl("phData"), PlaceHolder)

                ' Dim Quantity As String = DirectCastHolder1.FindControl("txtQuantity"), TextBox).Text
                Dim Tb As TextBox = TryCast(gr.FindControl("txtQuantity"), TextBox)
                Response.Write(Tb.Text)

                ' Dim Quantity As String = TryCast(gr.FindControl("txtQuantity"), TextBox).Text
                'Dim BrochureId As String = gr.Cells(3).Text.ToString()

                'If Not String.IsNullOrEmpty(Quantity) Then

                ' no need to create another variable gridRow and set it = gr

                'End If
            End If

        Next

        'End If
        '================================================

        ''For Each gr As GridViewRow In requestCart.Rows

        'Dim Quantity As String = DirectCast(gr.FindControl("txtQuantity"), TextBox).Text



        'Response.Write(Quantity)
        Response.End()


        'If Not (Quantity = String.Empty) Then
        'Dim gridRow As GridViewRow = gr
        Dim RequestItemId As Guid = System.Guid.NewGuid

        '===Set the ProductId andBrochureId and quantity,in the currently selected row.
        'Dim BrochureId As String = gridRow.Cells(3).Text.ToString
        'Dim ProductId As String = gridRow.Cells(4).Text.ToString
        ' Dim Quantity As String = DirectCast(gr.FindControl("TxtMSeriesQuantity"), TextBox).Text


        ' Dim CmdLiteratureItems As SqlCommand
        ' Dim StrLiteratureItemsInsert As String

        ' StrLiteratureItemsInsert = "Insert into LiteratureRequestItems values (@RequestItemId,@BrochureId,@RequestId,@ProductId,@Quantity);"


        ' CmdLiteratureItems = New SqlCommand(StrLiteratureItemsInsert, MyConn)

        '  CmdLiteratureItems.Parameters.Add(New SqlParameter("@RequestItemId", SqlDbType.UniqueIdentifier))
        ' CmdLiteratureItems.Parameters("@RequestItemId").Value = New SqlGuid(RequestItemId)

        ' CmdLiteratureItems.Parameters.Add(New SqlParameter("@BrochureId", SqlDbType.UniqueIdentifier))
        ' CmdLiteratureItems.Parameters("@BrochureId").Value = New SqlGuid(BrochureId)

        ' CmdLiteratureItems.Parameters.Add(New SqlParameter("@RequestId", SqlDbType.UniqueIdentifier))
        ' CmdLiteratureItems.Parameters("@RequestId").Value = New SqlGuid(RequestId)

        ' CmdLiteratureItems.Parameters.Add(New SqlParameter("@ProductId", SqlDbType.UniqueIdentifier))
        ' CmdLiteratureItems.Parameters("@ProductId").Value = New SqlGuid(ProductId)

        ' CmdLiteratureItems.Parameters.Add(New SqlParameter("@Quantity", SqlDbType.Int))
        ' CmdLiteratureItems.Parameters("@Quantity").Value = Integer.Parse(Quantity)

        ' If MyConn.State = ConnectionState.Closed Then
        'MyConn.Open()
        ' End If

        ' If MyConn.State = ConnectionState.Open Then
        ' CmdLiteratureItems.ExecuteNonQuery()
        'MyConn.Close()
        'End If

        'CmdLiteratureItems = Nothing
        'StrLiteratureItemsInsert = Nothing
        'RequestItemId = Nothing
        'ProductId = Nothing
        'BrochureId = Nothing
        'End If
        'Next

    End Function


    Public Sub SendMail()
        Dim mailmessage As New System.Net.Mail.MailMessage
        '==Get the SalesUSer email, who is requesting the literature

        Dim SalesUserEmailId As String
        Dim SalesuserId As Guid = New Guid(Session("SesUserId").ToString)
        Dim EmailRead As SqlDataReader
        Dim EmailId As String
        Dim LastName As String
        Dim Firstname As String

        '==='Get the Guid of the product Selected
        Dim StrChkEmail As String = String.Format("Select e_mail,Lastname,FirstName From SalesUsers where SalesUserId='{0}'", SalesuserId)

        Dim CmdSalesUserEmailId As SqlCommand = New SqlCommand(StrChkEmail, MyConn)
        If MyConn.State = ConnectionState.Closed Then
            MyConn.Open()
        End If
        If MyConn.State = ConnectionState.Open Then
            EmailRead = CmdSalesUserEmailId.ExecuteReader()

            While EmailRead.Read
                EmailId = EmailRead("e_mail").ToString
                LastName = EmailRead("LastName").ToString
                Firstname = EmailRead("FirstName").ToString
            End While
            MyConn.Close()
        End If

        EmailRead.Close()
        CmdSalesUserEmailId.Dispose()



        '===Send Mail
        mailmessage.From = New MailAddress(EmailId)
        mailmessage.To.Add(New MailAddress("mcabral@doble.com"))
        mailmessage.Bcc.Add(New MailAddress("snagaraj@doble.com"))
        mailmessage.Subject = "Testing:Request Literature"
        mailmessage.Body = "Testing: Request Literature From " & LastName & "," & Firstname

        Dim smtpClient As New SmtpClient()
        Dim userState As Object = mailmessage

        AddHandler smtpClient.SendCompleted, AddressOf Smtpclient_onCompleted

        Try
            'Send the email asynchronously
            smtpClient.SendAsync(mailmessage, userState)
        Catch smtpEx As SmtpException
            lblMessage.Text = smtpEx.Message
        Catch ex As Exception
            lblMessage.Text = ex.Message
        End Try
    End Sub

    Public Sub Smtpclient_onCompleted(ByVal Sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)

        Dim mailMessage As MailMessage = CType(e.UserState, MailMessage)


        If (e.Cancelled) Then
            lblMessage.Text = "Mail cancelled"
        End If
        If Not (e.Error Is Nothing) Then
            lblMessage.Text = "error Occured:" + e.Error.Message
        Else
            lblMessage.Text = "Your Request was Emailed."
        End If
    End Sub
    '=====Web method Called from javascript Check Country is in database,
    '===And give message if Country is notin Db.
    <System.Web.Services.WebMethod()> _
    Public Shared Function CheckCountryInDatabase(ByVal CounName As String) As String

        Dim MyConn As SqlConnection = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("StrConn"))

        If Not (CounName Is Nothing OrElse CounName.Length = 0) Then

            If MyConn.State = ConnectionState.Closed Then
                MyConn.Open()
            End If


            If MyConn.State = ConnectionState.Open Then

                Try
                    Dim StrCheckCountry As String
                    StrCheckCountry = String.Format("Select CountryRegionName From StateProvince where CountryRegionName='{0}'", CounName)

                    Dim CmdCheckCountry As SqlCommand = New SqlCommand(StrCheckCountry, MyConn)
                    Dim CounExist As String = Convert.ToString(CmdCheckCountry.ExecuteScalar())
                    If CounExist Is String.Empty Then
                        Return ("The Country You have Choosen does not exist in database.To add this Country,Send mail to admin" & CounExist)
                    Else
                        Return Nothing

                    End If

                Catch ex As SqlException
                    Return "error"
                Finally
                    MyConn.Close()

                End Try

            End If


        End If

    End Function
    Protected Sub RequestCart_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles requestCart.RowDataBound

        ' Hide the ProductID,BrochureId,ProductCategory column...
        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(3).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(3).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(3).Style.Add("display", "none")
        End If

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(4).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(4).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(4).Style.Add("display", "none")
        End If


    End Sub
    Protected Sub GrdMSeries_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GrdMSeries.RowDataBound

        ' Hide the ProductID,BrochureId,ProductCategory column...
        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(1).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(1).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(1).Style.Add("display", "none")
        End If

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(2).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(2).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(2).Style.Add("display", "none")
        End If

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(0).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(0).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(0).Style.Add("display", "none")
        End If



    End Sub
    Protected Sub GrdFSeries_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GrdFSeries.RowDataBound


        ' Hide the ProductID,BrochureId,ProductCategory column for Fseries...

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(1).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(1).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(1).Style.Add("display", "none")
        End If

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(2).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(2).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(2).Style.Add("display", "none")
        End If

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(0).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(0).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(0).Style.Add("display", "none")
        End If


    End Sub

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


        ' Hide the ProductID,BrochureId,ProductCategory column for TDR Series...

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(1).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(1).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(1).Style.Add("display", "none")
        End If

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(2).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(2).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(2).Style.Add("display", "none")
        End If

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(0).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(0).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(0).Style.Add("display", "none")
        End If


    End Sub
    Protected Sub GrdDominoIDDSeries_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GrdDominoIDDSeries.RowDataBound


        ' Hide the ProductID,BrochureId,ProductCategory column for TDR Series...

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(1).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(1).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(1).Style.Add("display", "none")
        End If

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(2).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(2).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(2).Style.Add("display", "none")
        End If

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(0).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(0).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(0).Style.Add("display", "none")
        End If


    End Sub
    Protected Sub GrdProOverviewServices_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GrdProOverviewServices.RowDataBound


        ' Hide the ProductID,BrochureId,ProductCategory column for TDR Series...

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(1).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(1).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(1).Style.Add("display", "none")
        End If

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(2).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(2).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(2).Style.Add("display", "none")
        End If

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(0).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(0).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(0).Style.Add("display", "none")
        End If


    End Sub

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


        ' Hide the ProductID,BrochureId,ProductCategory column for TDR Series...

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(1).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(1).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(1).Style.Add("display", "none")
        End If

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(2).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(2).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(2).Style.Add("display", "none")
        End If

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(0).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(0).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(0).Style.Add("display", "none")
        End If


    End Sub

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

        ' Hide the ProductID,BrochureId,ProductCategory column for TDR Series...

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(1).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(1).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(1).Style.Add("display", "none")
        End If

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(2).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(2).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(2).Style.Add("display", "none")
        End If

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(0).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(0).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(0).Style.Add("display", "none")
        End If


    End Sub

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


        ' Hide the ProductID,BrochureId,ProductCategory column for TDR Series...

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(1).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(1).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(1).Style.Add("display", "none")
        End If

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(2).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(2).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(2).Style.Add("display", "none")
        End If

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(0).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(0).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(0).Style.Add("display", "none")
        End If


    End Sub

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

        ' Hide the ProductID,BrochureId,ProductCategory column for TDR Series...

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(1).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(1).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(1).Style.Add("display", "none")
        End If

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(2).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(2).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(2).Style.Add("display", "none")
        End If

        If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.Cells(0).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Header Then
            e.Row.Cells(0).Style.Add("display", "none")
        ElseIf e.Row.RowType = DataControlRowType.Footer Then
            e.Row.Cells(0).Style.Add("display", "none")
        End If


    End Sub

End Class


'==Aspx page=======

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Copy of RequestLiterature.aspx.vb" Inherits="DobleRepCorner_Literature_RequestLiterature" MasterPageFile="~/SalesMaster.master" title="Request Literature" enableeventvalidation="false" viewstateencryptionmode="Never" validateRequest="false" Async="true"%>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>


<asp:Content ID="ContRequestLit" ContentPlaceHolderID="MainContent" Runat="Server" >
    <link href="../../Css/Gridview.css" rel="stylesheet" type="text/css" />
    <link href="../../Css/Sales.css" rel="stylesheet" type="text/css" />
    <link href="../../Css/AccordianAtyle.css" rel="stylesheet" type="text/css" />
    <link href="../../Css/AutoComplete.css" rel="stylesheet" type="text/css"/>
 <style type="text/css">

   .add {
      background:navy; color:lime}
   .remove {
      background:maroon; color:gold}

</style>
        <script type="text/javascript">
 
  
   /*  Pagemethod is used to check if the Country entred by user is in database.The code for searching is in Code behind */   
     function CheckCountryInDB(id)
   {
   var CheckCountryTextBox;
   var CheckCountry;
   CheckCountryTextBox=document.getElementById(id);
   CheckCountry=CheckCountryTextBox.value;
   if (CheckCountry!=null)
   {
   PageMethods.CheckCountryInDatabase(CheckCountry,CallSuccess,CallFailed);
   }
   }
   
   
   function CallSuccess(result)
 {     
         if(result!=null)
         {
         alert(result);
    var CheckCountryTextBox;
   CheckCountryTextBox=document.getElementById('<%=TxtCountry.ClientID%>');
   CheckCountryTextBox.value='';
         }
 }

function CallFailed(res)
 {
     alert(error.get_message());
          
 }
 
     /*  Validation for Quantity textboxes.Only Numeric values are allowed*/
   function checkNum(x)

{ 
  
  var s_len=x.value.length ; 
  var s_charcode = 0; 
    for (var s_i=0;s_i<s_len;s_i++) 
    { 
     s_charcode = x.value.charCodeAt(s_i); 
     if(!((s_charcode>=48 && s_charcode<=57))) 
      { 
         alert("Only Numeric Values Allowed in Quantity"); 
          x.value=''; 
         x.focus(); 
        return false; 
      } 
    } 
    return true; 
} 

/*  Validation to Check if atleast one Itme is present in Request cart, before submit.if it is there Quantity textbox should not be blank*/
 
 function GridViewValidate()

    {
      Page_ClientValidate('ContactShipping');
   
     /*  Validation for Request Cart*/
    var grid = document.getElementById('<%=requestCart.ClientID %>');
    var bool=0; 
    if(grid!=null) 
            
            { 
                  
                         
              var Inputs = grid.getElementsByTagName("input"); 
                 if(Inputs.length==0)
                 {
                 alert('Input atleast One item of Request Literature before you submit');
                 return false;
                 }
                    for(i = 0; i < Inputs.length; i++)
                    {
                    
                     if(Inputs[i].type =="text")
                         {
                         if(Inputs[i].value=="")
                          {
                          alert('One of the Quantity textbox is empty.Please enter it.');
                          return false;
                          }
                         }

                    }
                   
            }
           
    
   
    }

      </script>
<form id="form1" action="">
      <asp:ScriptManager ID="ScriptManagerLiteratureRequest"  runat="server" EnablePartialRendering="true" EnablePageMethods="true">
  <Services>
        <asp:ServiceReference Path="~/WebService/AutoComCountry.asmx" />
         <asp:servicereference path="~/WebService/CheckCountryInDB.asmx"></asp:servicereference>
  </Services>
   </asp:ScriptManager>
     <h2 class="h2" align="center">Request Product Literature</h2>
      <h5 class="h5" align="center" style=" background-color: Aqua">When you submit the form,an email will be sent to Brochure maintainance team</h5>
      <h5 class="h5" align="center" style=" background-color: Aqua">Fax: 617-926-0528, E-mail: brochures@doble.com</h5>
       
        <asp:Label ID="lblMessage" runat="server" CssClass="Messagelabel"></asp:Label>
         <table align="center">
         <tr><td  class ="th">Contact Name :</td><td><asp:TextBox ID="TxtName" runat="server" MaxLength="50" TabIndex="0" ValidationGroup="ContactShipping"></asp:TextBox></td><td class ="th">Company :</td><td><asp:TextBox ID="TxtNameOfCompany" runat="server" MaxLength="50" TabIndex="1" ValidationGroup="ContactShipping"></asp:TextBox></td></tr>
    <tr>
        <td  class ="th">Ship to Address Line 1:</td><td><asp:TextBox ID="TxtShipToAddress1" runat="server" MaxLength="80" TabIndex="2" ValidationGroup="ContactShipping"></asp:TextBox></td>
       <td  class ="th">Address Line 2:</td><td><asp:TextBox ID="TxtShipToAddress2" runat="server" MaxLength="80" TabIndex="3"></asp:TextBox></td>
    </tr>
     <tr>
     <td  class ="th">City:</td><td><asp:TextBox ID="TxtCity" runat="server" MaxLength="60" TabIndex="4" ValidationGroup="ContactShipping"></asp:TextBox></td>
     <td  class ="th">State:</td><td><asp:TextBox ID="TxtState"  runat="server" MaxLength="60" TabIndex="5" ValidationGroup="ContactShipping"></asp:TextBox></td>
    </tr>
     <tr>
     <td  class ="th">Country:</td><td><asp:TextBox ID="TxtCountry" runat="server" onblur="javascript:CheckCountryInDB(this.id);" TabIndex="6" ValidationGroup="ContactShipping"></asp:TextBox>
     <cc1:AutoCompleteExtender ID="ACCountry" runat="server" CompletionInterval="500" 
                        CompletionListCssClass="AutoExtender" 
                        CompletionListHighlightedItemCssClass="AutoExtenderHighlight" 
                        CompletionListItemCssClass="AutoExtenderList" CompletionSetCount="12" 
                        EnableCaching="true" MinimumPrefixLength="1" ServiceMethod="GetCountryList" 
                        ServicePath="~/WebService/AutoComCountry.asmx" TargetControlID="TxtCountry">
                    </cc1:AutoCompleteExtender></td>
    <td class ="th">ZipCode:</td><td><asp:TextBox ID="TxtZipCode" runat="server" MaxLength="50" TabIndex="7" ValidationGroup="ContactShipping"></asp:TextBox></td>
   </tr>
   <tr><td  class ="th">Phone:</td><td><asp:TextBox ID="txtPhone" runat="server" MaxLength="13" TabIndex="8" ValidationGroup="ContactShipping"></asp:TextBox></td>
        <td class ="th"> Fax :</td><td><asp:TextBox ID="TxtFax" runat="server" MaxLength="13" TabIndex="9" ValidationGroup="ContactShipping"></asp:TextBox></td>
    </tr>
   <tr><td  class ="th">Comments :</td><td>
       <asp:TextBox ID="TxtComments" runat="server" TextMode="MultiLine" TabIndex="10" ValidationGroup="ContactShipping"></asp:TextBox>
       </td>
           </tr>
     </table>
   <asp:RequiredFieldValidator ID="ReqValAddress1" runat="server" ErrorMessage="Shipping Address Line 1" ControlToValidate="TxtShipToAddress1" Display="None" SetFocusOnError="true"></asp:RequiredFieldValidator>
   <cc1:ValidatorCalloutExtender ID="ExtenderRegExAddress1" runat="server" targetcontrolid="ReqValAddress1"/>
   
   <asp:RequiredFieldValidator ID="ReqValCity" runat="server" ErrorMessage="Shipping City" ControlToValidate="TxtCity"  Display="None" SetFocusOnError="true"></asp:RequiredFieldValidator>
   <cc1:ValidatorCalloutExtender ID="ExtenderCity" runat="server" targetcontrolid="ReqValCity"/>
  
  <asp:RequiredFieldValidator ID="ReqValState" runat="server" ErrorMessage="Shipping State" ControlToValidate="TxtState" Display="None" SetFocusOnError="true"></asp:RequiredFieldValidator>
  <cc1:ValidatorCalloutExtender ID="ExtenderState" runat="server" targetcontrolid="ReqValState"/>
  
 <asp:RequiredFieldValidator ID="ReqValZipCode" runat="server" ErrorMessage="ZipCode" ControlToValidate="TxtZipCode" Display="None" SetFocusOnError="true" ></asp:RequiredFieldValidator>
 <cc1:ValidatorCalloutExtender ID="ExtenderZipCode" runat="server" targetcontrolid="ReqValZipCode"/>
 
<asp:RequiredFieldValidator ID="ReqCountry" runat="server" ErrorMessage="Country" ControlToValidate="TxtCountry" Display="None" SetFocusOnError="true"></asp:RequiredFieldValidator>
<cc1:ValidatorCalloutExtender ID="ExtenderReqCountry" runat="server" targetcontrolid="ReqCountry"/>

<asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="ContactShipping"/>
<br />
 <table align="center"><tr>
     <td><asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick="javascript:return GridViewValidate();"/></td>
    </tr></table>
   <h5 class="h5" align="center" style=" background-color: Aqua">Please add all Items needed and then enter quantity</h5> 
<!-- <asp:UpdatePanel ID="UpdatePanelRequestCart" runat="server" UpdateMode="Conditional" >
  <ContentTemplate> -->
<table align="center"><tr>
<td class ="th"  align="center">Request Cart
       <asp:GridView ID="requestCart" runat="server"
         cellpadding="5" font-size="8pt"
         headerstyle-backcolor="gray"
         headerstyle-forecolor="khaki"
         rowstyle-backcolor="ivory"
        EmptyDataText ="Select  Request Items into the Cart"
         rowstyle-verticalalign="top" onRowCommand="Requestcart_UpateRequestCart" onRowCreated="RequestCart_RowCreated">
         <Columns>
         
        <asp:buttonfield HeaderText="Remove" text=" - " buttontype="button" commandname="RemoveFromCart"/>   
         <asp:TemplateField HeaderText="Quantity">
            <ItemTemplate>
                <!-- Dynamically adding a TextBox here causes problems 
                <asp:PlaceHolder ID="phData" runat="server" />-->
                 <asp:TextBox ID="txtQuantity" runat="server"></asp:TextBox>
            </ItemTemplate>
        </asp:TemplateField>
                       </Columns>
       </asp:GridView>
        
   </td></tr>
</table>
 <!-- </ContentTemplate>
                </asp:UpdatePanel>-->
    <cc1:Accordion ID="AccoRequestLiterature" runat="server"
    ContentCssClass="accordionContent"
    HeaderCssClass="accordionHeader"
    SelectedIndex="0"
    HeaderSelectedCssClass="accordionHeaderSelected"
    AutoSize="None"
    FadeTransitions="true"
    TransitionDuration="250"
    FramesPerSecond="40"
    RequireOpenedPane="false"
    SuppressHeaderPostbacks="true">

    <Panes>
        <cc1:AccordionPane ID="AccPanSection1" runat="server" BackColor="gray">
        <Header>Section M Series</Header>
        <Content>
        <table  border="1" class="table">
        <tr>
        <td>
         <asp:GridView ID="GrdMSeries"  CssClass="tabulardata" 
        runat="server" AllowSorting="True" AutoGenerateColumns="False" 
       emptydatatext="No Brochures available." DataSourceID="SQLMSeries" onRowCreated="setButtonStyle"
      onRowCommand="updateCart">
      <Columns>
        <asp:BoundField DataField="ProductId"/>
            <asp:BoundField DataField="BrochureId"/>
            <asp:BoundField DataField="ProductCategory" />
           <asp:BoundField DataField="BrochureName" HeaderText="Brochure Name" SortExpression="BrochureName" />
           <asp:BoundField DataField="Revision" HeaderText="Revision" SortExpression="Revision" />
           <asp:buttonfield HeaderText="Add" text=" + "  buttontype="button" commandname="AddToCart"/>
    </Columns>
       </asp:GridView>
       <asp:SqlDataSource ID="SQLMSeries" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SalesRepActivityConnectionString %>" 
        SelectCommand="SELECT Products.ProductId,ProductBrochure.BrochureId ,Products.ProductName, Products.ProductCategory, ProductBrochure.BrochureName, ProductBrochure.Revision
                        FROM  Products INNER JOIN ProductBrochure ON Products.ProductId = ProductBrochure.ProductId 
                        Where  Products.ProductCategory='Mseries' order by productcategory"></asp:SqlDataSource>
       </td>     
        </tr>
        </table>
        </Content>
        </cc1:AccordionPane>
       
         <cc1:AccordionPane ID="AccPanSection2" runat="server" BackColor="gray">
        <Header>Section FSeries</Header>
        <Content>
         <table  border="1" class="table">
        <tr>
        <td>
         <asp:GridView ID="GrdFSeries"  CssClass="tabulardata" 
        runat="server" AllowSorting="True" AutoGenerateColumns="False" 
       emptydatatext="No Brochures available." DataSourceID="SQLFSeries" onRowCreated="setButtonStyle"
      onRowCommand="updateCart">
       <Columns>
            <asp:BoundField DataField="ProductId"/>
            <asp:BoundField DataField="BrochureId"/>
            <asp:BoundField DataField="ProductCategory" />
           <asp:BoundField DataField="BrochureName" HeaderText="Brochure Name" SortExpression="BrochureName" />
           <asp:BoundField DataField="Revision" HeaderText="Revision" SortExpression="Revision" />
           <asp:buttonfield HeaderText="Add" text=" + "  buttontype="button" commandname="AddToCart"/>
        </Columns>
       </asp:GridView>
       <asp:SqlDataSource ID="SQLFSeries" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SalesRepActivityConnectionString %>" 
        SelectCommand="SELECT Products.ProductId,ProductBrochure.BrochureId ,Products.ProductName, Products.ProductCategory, ProductBrochure.BrochureName, ProductBrochure.Revision
                        FROM  Products INNER JOIN ProductBrochure ON Products.ProductId = ProductBrochure.ProductId 
                        Where  Products.ProductCategory='Fseries' order by productcategory"></asp:SqlDataSource>
        </td>
        </tr>
        </table>
        
        </Content>
        </cc1:AccordionPane>
        
      
        <cc1:AccordionPane ID="AccPanSection3" runat="server" BackColor="gray">
        <Header>Section TDR Series</Header>
        <Content>
         <table  border="1" class="table">
        <tr>
        <td>
         <asp:GridView ID="GrdTDRSeries"  CssClass="tabulardata" 
        runat="server" AllowSorting="True" AutoGenerateColumns="False" 
       emptydatatext="No Brochures available." DataSourceID="SQLTDRSeries" onRowCreated="setButtonStyle" onRowCommand="updateCart">
       <Columns>
         <asp:BoundField DataField="ProductId"/>
            <asp:BoundField DataField="BrochureId"/>
            <asp:BoundField DataField="ProductCategory" />
           <asp:BoundField DataField="BrochureName" HeaderText="Brochure Name" SortExpression="BrochureName" />
           <asp:BoundField DataField="Revision" HeaderText="Revision" SortExpression="Revision" />
          <asp:buttonfield HeaderText="Add" text=" + "  buttontype="button" commandname="AddToCart"/>
        </Columns>
       </asp:GridView>
       <asp:SqlDataSource ID="SQLTDRSeries" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SalesRepActivityConnectionString %>" 
        SelectCommand="SELECT Products.ProductId,ProductBrochure.BrochureId ,Products.ProductName, Products.ProductCategory, ProductBrochure.BrochureName, ProductBrochure.Revision
                        FROM  Products INNER JOIN ProductBrochure ON Products.ProductId = ProductBrochure.ProductId 
                        Where  Products.ProductCategory='TDRseries' order by productcategory"></asp:SqlDataSource>
       </td>
        </tr>
        </table>
        
        </Content>
        </cc1:AccordionPane>
        
        
        <cc1:AccordionPane ID="AccPanSection4" runat="server" BackColor="gray">
        <Header>Section Domino & IDD</Header>
        <Content>
         <table  border="1" class="table">
        <tr>
        <td>
         <asp:GridView ID="GrdDominoIDDSeries"  CssClass="tabulardata" 
        runat="server" AllowSorting="True" AutoGenerateColumns="False" 
       emptydatatext="No Brochures available." DataSourceID="SQLDominoIDDSeries"
       onRowCreated="setButtonStyle" onRowCommand="updateCart">
       <Columns>
          <asp:BoundField DataField="ProductId"/>
            <asp:BoundField DataField="BrochureId"/>
            <asp:BoundField DataField="ProductCategory" />
           <asp:BoundField DataField="BrochureName" HeaderText="Brochure Name" SortExpression="BrochureName" />
           <asp:BoundField DataField="Revision" HeaderText="Revision" SortExpression="Revision" />
           <asp:buttonfield HeaderText="Add" text=" + "  buttontype="button" commandname="AddToCart"/>
         </Columns>
       </asp:GridView>
       <asp:SqlDataSource ID="SQLDominoIDDSeries" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SalesRepActivityConnectionString %>" 
        SelectCommand="SELECT Products.ProductId,ProductBrochure.BrochureId ,Products.ProductName, Products.ProductCategory, ProductBrochure.BrochureName, ProductBrochure.Revision
                        FROM  Products INNER JOIN ProductBrochure ON Products.ProductId = ProductBrochure.ProductId 
                        Where  Products.ProductCategory='IDD' or Products.ProductCategory='Domino'order by productcategory"></asp:SqlDataSource>
       </td>
        </tr>
        </table>
        
        </Content>
        </cc1:AccordionPane>
        
        <cc1:AccordionPane ID="AccPanSection5" runat="server" BackColor="gray">
        <Header>Product Overview & Services</Header>
        <Content>
         <table  border="1" class="table">
        <tr>
        <td>
         <asp:GridView ID="GrdProOverviewServices"  CssClass="tabulardata" 
        runat="server" AllowSorting="True" AutoGenerateColumns="False" 
       emptydatatext="No Brochures available." DataSourceID="SQLGrdProOverviewServices"
       onRowCreated="setButtonStyle" onRowCommand="updateCart">
       <Columns>
          <asp:BoundField DataField="ProductId"/>
            <asp:BoundField DataField="BrochureId"/>
            <asp:BoundField DataField="ProductCategory" />
           <asp:BoundField DataField="BrochureName" HeaderText="Brochure Name" SortExpression="BrochureName" />
           <asp:BoundField DataField="Revision" HeaderText="Revision" SortExpression="Revision" />
           <asp:buttonfield HeaderText="Add" text=" + "  buttontype="button" commandname="AddToCart"/>
         </Columns>
       </asp:GridView>
       <asp:SqlDataSource ID="SQLGrdProOverviewServices" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SalesRepActivityConnectionString %>" 
        SelectCommand="SELECT Products.ProductId,ProductBrochure.BrochureId ,Products.ProductName, Products.ProductCategory, ProductBrochure.BrochureName, ProductBrochure.Revision
                        FROM  Products INNER JOIN ProductBrochure ON Products.ProductId = ProductBrochure.ProductId 
                        Where  Products.ProductCategory='Product Overview Services' order by productcategory"></asp:SqlDataSource>
       </td>
        </tr>
        </table>
        
        </Content>
        </cc1:AccordionPane>
        
        <cc1:AccordionPane ID="AccordionPane6" runat="server" BackColor="gray">
        <Header>DSA & Services</Header>
        <Content>
         <table  border="1" class="table">
        <tr>
        <td>
         <asp:GridView ID="GrdDSAServices"  CssClass="tabulardata" 
        runat="server" AllowSorting="True" AutoGenerateColumns="False" 
       emptydatatext="No Brochures available." DataSourceID="SQLDSAServices"
       onRowCreated="setButtonStyle" onRowCommand="updateCart">
       <Columns>
          <asp:BoundField DataField="ProductId"/>
            <asp:BoundField DataField="BrochureId"/>
            <asp:BoundField DataField="ProductCategory" />
           <asp:BoundField DataField="BrochureName" HeaderText="Brochure Name" SortExpression="BrochureName" />
           <asp:BoundField DataField="Revision" HeaderText="Revision" SortExpression="Revision" />
           <asp:buttonfield HeaderText="Add" text=" + "  buttontype="button" commandname="AddToCart"/>
         </Columns>
       </asp:GridView>
       <asp:SqlDataSource ID="SQLDSAServices" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SalesRepActivityConnectionString %>" 
        SelectCommand="SELECT Products.ProductId,ProductBrochure.BrochureId ,Products.ProductName, Products.ProductCategory, ProductBrochure.BrochureName, ProductBrochure.Revision
                        FROM  Products INNER JOIN ProductBrochure ON Products.ProductId = ProductBrochure.ProductId 
                        Where  Products.ProductCategory='DSA & Services' order by productcategory"></asp:SqlDataSource>
       </td>
        </tr>
        </table>
        
        </Content>
        </cc1:AccordionPane>
        
        <cc1:AccordionPane ID="AccPanSection7" runat="server" BackColor="gray">
        <Header>Partial Discharge Detection Services</Header>
        <Content>
         <table  border="1" class="table">
        <tr>
        <td>
         <asp:GridView ID="GrdPDD"  CssClass="tabulardata" 
        runat="server" AllowSorting="True" AutoGenerateColumns="False" 
       emptydatatext="No Brochures available." DataSourceID="SQLPDD"
       onRowCreated="setButtonStyle" onRowCommand="updateCart">
       <Columns>
          <asp:BoundField DataField="ProductId"/>
            <asp:BoundField DataField="BrochureId"/>
            <asp:BoundField DataField="ProductCategory" />
           <asp:BoundField DataField="BrochureName" HeaderText="Brochure Name" SortExpression="BrochureName" />
           <asp:BoundField DataField="Revision" HeaderText="Revision" SortExpression="Revision" />
           <asp:buttonfield HeaderText="Add" text=" + "  buttontype="button" commandname="AddToCart"/>
         </Columns>
       </asp:GridView>
       <asp:SqlDataSource ID="SQLPDD" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SalesRepActivityConnectionString %>" 
        SelectCommand="SELECT Products.ProductId,ProductBrochure.BrochureId ,Products.ProductName, Products.ProductCategory, ProductBrochure.BrochureName, ProductBrochure.Revision
                        FROM  Products INNER JOIN ProductBrochure ON Products.ProductId = ProductBrochure.ProductId 
                        Where  Products.ProductCategory='PD' order by productcategory"></asp:SqlDataSource>
       </td>
        </tr>
        </table>
        
        </Content>
        </cc1:AccordionPane>
        
        <cc1:AccordionPane ID="AccPanSection8" runat="server" BackColor="gray">
        <Header>Doble Global Power Services (GPS)</Header>
        <Content>
         <table  border="1" class="table">
        <tr>
        <td>
         <asp:GridView ID="GrdGPS"  CssClass="tabulardata" 
        runat="server" AllowSorting="True" AutoGenerateColumns="False" 
       emptydatatext="No Brochures available." DataSourceID="SQLGPS"
       onRowCreated="setButtonStyle" onRowCommand="updateCart">
       <Columns>
          <asp:BoundField DataField="ProductId"/>
            <asp:BoundField DataField="BrochureId"/>
            <asp:BoundField DataField="ProductCategory" />
           <asp:BoundField DataField="BrochureName" HeaderText="Brochure Name" SortExpression="BrochureName" />
           <asp:BoundField DataField="Revision" HeaderText="Revision" SortExpression="Revision" />
           <asp:buttonfield HeaderText="Add" text=" + "  buttontype="button" commandname="AddToCart"/>
         </Columns>
       </asp:GridView>
       <asp:SqlDataSource ID="SQLGPS" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SalesRepActivityConnectionString %>" 
        SelectCommand="SELECT Products.ProductId,ProductBrochure.BrochureId ,Products.ProductName, Products.ProductCategory, ProductBrochure.BrochureName, ProductBrochure.Revision
                        FROM  Products INNER JOIN ProductBrochure ON Products.ProductId = ProductBrochure.ProductId 
                        Where  Products.ProductCategory='Doble Global Power Services-GPS' order by productcategory"></asp:SqlDataSource>
       </td>
        </tr>
        </table>
        
        </Content>
        </cc1:AccordionPane>
        
        <cc1:AccordionPane ID="AccordionPane1" runat="server" BackColor="gray">
        <Header> Doble Product CDs and Giveways</Header>
        <Content>
         <table  border="1" class="table">
        <tr>
        <td>
         <asp:GridView ID="GrdGiveaways"  CssClass="tabulardata" 
        runat="server" AllowSorting="True" AutoGenerateColumns="False" 
       emptydatatext="No Brochures available." DataSourceID="SQLGiveaways"
       onRowCreated="setButtonStyle" onRowCommand="updateCart">
       <Columns>
          <asp:BoundField DataField="ProductId"/>
            <asp:BoundField DataField="BrochureId"/>
            <asp:BoundField DataField="ProductCategory" />
           <asp:BoundField DataField="BrochureName" HeaderText="Brochure Name" SortExpression="BrochureName" />
           <asp:BoundField DataField="Revision" HeaderText="Revision" SortExpression="Revision" />
           <asp:buttonfield HeaderText="Add" text=" + "  buttontype="button" commandname="AddToCart"/>
         </Columns>
       </asp:GridView>
       <asp:SqlDataSource ID="SQLGiveaways" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SalesRepActivityConnectionString %>" 
        SelectCommand="SELECT Products.ProductId,ProductBrochure.BrochureId ,Products.ProductName, Products.ProductCategory, ProductBrochure.BrochureName, ProductBrochure.Revision
                        FROM  Products INNER JOIN ProductBrochure ON Products.ProductId = ProductBrochure.ProductId 
                        Where  Products.ProductCategory='Doble Product Cds/Giveaways' order by productcategory"></asp:SqlDataSource>
       </td>
        </tr>
        </table>
        
        </Content>
        </cc1:AccordionPane>
        
    </Panes>
    </cc1:Accordion>
    
        </form>
</asp:Content>

Open in new window

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 26108185
How are you defining the GridView, with the TextBox in the ItemTemplate?
0
 
LVL 1

Author Comment

by:SaraDob
ID: 26108346
The LearnedOne,
I have put it on an aspx page...
 
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 26108384
No, I meant can you show me just the HTML for that piece, please?
0
 
LVL 1

Author Comment

by:SaraDob
ID: 26108416

Here It Comes..The aspx page, where the  html of the gridview is there.
Now my concern is the page_load event...I tried to modify it for Page. Is post back and otherwise, it is causing a lot of problems..


<asp:GridView ID="requestCart" runat="server" 
cellpadding="5" font-size="8pt" 
headerstyle-backcolor="gray" 
headerstyle-forecolor="khaki" 
rowstyle-backcolor="ivory" 
EmptyDataText ="Select Request Items into the Cart" 
rowstyle-verticalalign="top" onRowCommand="Requestcart_UpateRequestCart" onRowCreated="RequestCart_RowCreated"> 
<Columns> 

<asp:buttonfield HeaderText="Remove" text=" - " buttontype="button" commandname="RemoveFromCart"/> 
<asp:TemplateField HeaderText="Quantity"> 
<ItemTemplate> 
<!-- Dynamically adding a TextBox here causes problems 
<asp:PlaceHolder ID="phData" runat="server" />--> 
<asp:TextBox ID="txtQuantity" runat="server"></asp:TextBox> 
</ItemTemplate> 
</asp:TemplateField> 
</Columns> 
</asp:GridView>

Open in new window

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 26108436
What did you need for this TextBox to do?

What is this line for?

    tb.Columns = "10"
0
 
LVL 1

Author Comment

by:SaraDob
ID: 26108529
The Request cart is a Gridview, where the User Select their Product Brochures into(From other gridViews).
When they Select it, They will Enter The quantity into the textbox.
I thought , it will restrict the Users enetring more than 10 columns. But anyway now that i have commented it , as i'm not adding textbox dynamcalli, i dont need it.
 
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 26108549
If you need to enter a quantity in that TextBox, then you need to bind it to a column on the data source.

Example:

   <asp:TextBox ID="txtQuantity" runat="server" text='<%# Eval("Quantity") %>' />
0
 
LVL 1

Author Comment

by:SaraDob
ID: 26108586
The RequestCart GridView does not get anything from the database.It is a Gridview which gets populated On selection of Other products.
So If i enter  text='<%# Eval("Quantity") %>' in that textbox, it will look for dataBinding, which does not exist.
Well this is the Error I got :
System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Quantity'.

 
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 26108607
Actually, you don't NEED to bind, since you are handling that in code.  

Can you show me the code where you are trying to get a reference to "txtQuantity" with FindControl?
0
 
LVL 1

Author Comment

by:SaraDob
ID: 26112790
Sorry... That was the EOD at office.. so could not reply to that..
Thanks for staying with me on This. I hope i ca really hit it todat ..
i have pasted the code, where i get the Findcontrol.
I have removed the place holder now

Private Function CallRequestCartInsert(ByVal RequestId As Guid) As Boolean

      

     
        For Each gr As GridViewRow In requestCart.Rows

            '============================================
            If gr.RowType = DataControlRowType.DataRow Then

                ' Dim Holder1 As PlaceHolder = DirectCast(gr.FindControl("phData"), PlaceHolder)

                ' Dim Quantity As String = DirectCastHolder1.FindControl("txtQuantity"), TextBox).Text
                Dim Tb As TextBox = TryCast(gr.FindControl("txtQuantity"), TextBox)
                Response.Write(Tb.Text)

                ' Dim Quantity As String = TryCast(gr.FindControl("txtQuantity"), TextBox).Text
                'Dim BrochureId As String = gr.Cells(3).Text.ToString()

                'If Not String.IsNullOrEmpty(Quantity) Then

                ' no need to create another variable gridRow and set it = gr

                'End If
            End If

        Next

        'End If

Open in new window

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 26112882
I am thinking that you are calling "CallRequestCartInsert" from the RowCreated event handler, which is probably not the correct place.  I would try in the RowDataBound event handler instead.
0
 
LVL 1

Author Comment

by:SaraDob
ID: 26113026
Umm ..
When i click on Submit button, I call A private function to insert the requestCart Items.
I'm getting all other items in the request cart except the Textbox value.
 
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 26113047
"I call A private function to insert the requestCart Items"
I don't see where you are doing that...
0
 
LVL 1

Author Comment

by:SaraDob
ID: 26113090
here you go..
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        Updatedatabase()
        ' SendMail()
    End Sub

   Public Sub Updatedatabase()
 '====Insert The shipping Details

CallRequestCartInsert(RequestId)
end sub

Private Function CallRequestCartInsert(ByVal RequestId As Guid) As Boolean
  For Each gr As GridViewRow In requestCart.Rows

            '============================================
            If gr.RowType = DataControlRowType.DataRow Then

                ' Dim Holder1 As PlaceHolder = DirectCast(gr.FindControl("phData"), PlaceHolder)

                ' Dim Quantity As String = DirectCastHolder1.FindControl("txtQuantity"), TextBox).Text
                Dim Tb As TextBox = TryCast(gr.FindControl("txtQuantity"), TextBox)
           
                ' Dim Quantity As String = TryCast(gr.FindControl("txtQuantity"), TextBox).Text
                Dim BrochureId As String = gr.Cells(3).Text.ToString()
                Response.Write(BrochureId)

                'If Not String.IsNullOrEmpty(Quantity) Then

                ' no need to create another variable gridRow and set it = gr

                'End If
            End If

        Next

End Sub

Open in new window

0
 
LVL 1

Author Comment

by:SaraDob
ID: 26113163
TheLearnedOne,
Can you please let me know , if there are changes to be made in Page_load .I'm suspecting the value of teh textbox is lost there.
Is it something to do with datacart or view. Can i put the textbox value into an array ?
 
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 26113727
I think that the view that I have into your problem is too narrow, and I can't see the "big picture"...

Maybe you can take a little time to describe:

1) GridView data source

2) Page_Load

3) Processing steps

Defining a TextBox in an ItemTemplate should be a simple operation, which should give you access in the GridViewRow.FindControl, so we need to find the culprit (hopefully not a needle in a haystack).
0
 
LVL 1

Author Comment

by:SaraDob
ID: 26114146
TheLeranedOne,
I know Why you are getting confused.
1) There is no Datasource for the Request cart Gridview.This gridview is the one, i populate , when the User Clicks on Other Gridviews, with "+". The other Grdiviews have datasource based on product category.
2) In the Page_load
              This is where , i create a dataCart of the requestCart and put it in session.
               
I feel the textbox quantity is lost here upon postbackBut dunno how to retain it.          
3)Processing Steps:
                     3a) On Page load I create 5-6 Gridviews, Which are Populated based On product categories.This Gridviews has product Id, productname, The brochureName brochureId and buttonfield with  "+"  sign.the + sign has a command name"Updatecart".
                      3b) On aspx page There is Empty RequestCart gridview.I have In Itemtemplate a Textbox .It has a " - " Sign  button filed, where uSer can remove the Brochure, if not needed.
                    3c) When the user Click on "+" sign, UpdateCart is called.Where The brochureName, brochureId is added to requestcart. i have added the code behind for it
(Public Sub updateCart).
                       3d)The user enters Quantity and Hits submit Button. On BtnSubmit, I call UpdateShippingDetails(Address to be shipped, which is irrevalant here..) and call InsertRequestcart items (Public Function CallRequestCartInsert)
I hope i'm clear and it helps. Do Something...................( Pleading )
 

Public Sub updateCart(ByVal src As [Object], ByVal e As GridViewCommandEventArgs)

        Dim dr As DataRow = Cart.NewRow()

        ' get the row index stored in the CommandArgument property 
        Dim index As Integer = Convert.ToInt32(e.CommandArgument)

        ' get the GridViewRow where the command is raised 
        Dim selectedRow As GridViewRow = DirectCast(e.CommandSource, GridView).Rows(index)

        ' for bound fields, values are stored in the Text property of Cells [ fieldIndex ] 

        Dim BrochureName As String = selectedRow.Cells(3).Text
        Dim BrochureId As String = selectedRow.Cells(1).Text
        Dim Productid As String = selectedRow.Cells(0).Text
        ' Dim MaintainOld As DataTable


        If e.CommandName = "AddToCart" Then

            dr(0) = BrochureName
            dr(1) = BrochureId
            dr(2) = Productid


            Cart.Rows.Add(dr)


        End If

        requestCart.DataSource = CartView

        requestCart.DataBind()

'==================================
Public Function CallRequestCartInsert(ByVal RequestId As Guid) As Boolean

        ' Dim mpContentPlaceHolder As ContentPlaceHolder
        'mpContentPlaceHolder = CType(Master.FindControl("RequestContent"), ContentPlaceHolder)


        '  If Not mpContentPlaceHolder Is Nothing Then


        For Each gr As GridViewRow In requestCart.Rows

            '============================================
            If gr.RowType = DataControlRowType.DataRow Then

                ' Dim Holder1 As PlaceHolder = DirectCast(gr.FindControl("phData"), PlaceHolder)

                ' Dim Quantity As String = DirectCastHolder1.FindControl("txtQuantity"), TextBox).Text
                Dim Tb As TextBox = TryCast(gr.FindControl("txtQuantity"), TextBox)

                ' Dim Quantity As String = TryCast(gr.FindControl("txtQuantity"), TextBox).Text
                Dim BrochureId As String = gr.Cells(3).Text.ToString()
                Response.Write(BrochureId)

                'If Not String.IsNullOrEmpty(Quantity) Then

                ' no need to create another variable gridRow and set it = gr

                'End If
            End If

        Next
'======================On Page Load===================
 If Session("shoppingSession") Is Nothing And Not (Page.IsPostBack) Then
            Cart = New DataTable()

            Cart.Columns.Add(New DataColumn("BrochureName", GetType(String)))
            Cart.Columns.Add(New DataColumn("BrochureId", GetType(String)))
            Cart.Columns.Add(New DataColumn("ProductID", GetType(String)))
            Cart.Columns.Add(New DataColumn("Quantity", GetType(String)))

            Session("shoppingSession") = Cart

        ElseIf Not (Session("shoppingSession") Is Nothing) And Page.IsPostBack Then


            Cart = DirectCast(Session("shoppingSession"), DataTable)
        End If

        CartView = New DataView(Cart)
        requestCart.DataSource = CartView


        requestCart.DataBind()

Open in new window

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 26114335
Hmmm...I see this code in the Page_Load:

 Cart = New DataTable()

            Cart.Columns.Add(New DataColumn("BrochureName", GetType(String)))
            Cart.Columns.Add(New DataColumn("BrochureId", GetType(String)))
            Cart.Columns.Add(New DataColumn("ProductID", GetType(String)))
            Cart.Columns.Add(New DataColumn("Quantity", GetType(String)))

            Session("shoppingSession") = Cart

        ElseIf Not (Session("shoppingSession") Is Nothing) And Page.IsPostBack Then


            Cart = DirectCast(Session("shoppingSession"), DataTable)
        End If

        CartView = New DataView(Cart)
        requestCart.DataSource = CartView

It looks you are creating a data source for the cart, that includes the Quantity column.  I would think that if you bound the txtQuantity TextBox to the Quantity column, that it would be persisted between post-back.
0
 
LVL 1

Author Comment

by:SaraDob
ID: 26114593
Ummm..
I'm not too sure of doing this...can you help in putting this code together My knowlwdge ends here ...
i'm trying to Put Session"UpdateRequestCart") to dataview in ( if Page is Postback ).But i get error..Am i doing the right way.
 
 
0
 
LVL 1

Author Comment

by:SaraDob
ID: 26114655
I tried this..But I'm getting error in:
 
Dim dr As DataRow = Cart.NewRow() In
Public Sub updateCart(ByVal src As [Object], ByVal e As GridViewCommandEventArgs)
Error:Object reference not set to an instance of an object.

 
 

If Session("shoppingSession") Is Nothing And Not (Page.IsPostBack) Then
            Cart = New DataTable()

            Cart.Columns.Add(New DataColumn("BrochureName", GetType(String)))
            Cart.Columns.Add(New DataColumn("BrochureId", GetType(String)))
            Cart.Columns.Add(New DataColumn("ProductID", GetType(String)))
            'Cart.Columns.Add(New DataColumn("Quantity", GetType(String)))

            Session("shoppingSession") = Cart

        ElseIf Page.IsPostBack Then


            Cart = DirectCast(Session("NewUpdated"), DataTable)

        ElseIf Not (Session("shoppingSession") Is Nothing) Then

            Cart = DirectCast(Session("shoppingSession"), DataTable)

        End If


        CartView = New DataView(Cart)
        requestCart.DataSource = CartView


        requestCart.DataBind()
    End Sub
    '====Adding the Selected Items to the request cart
    Public Sub updateCart(ByVal src As [Object], ByVal e As GridViewCommandEventArgs)

        Dim dr As DataRow = Cart.NewRow()

        ' get the row index stored in the CommandArgument property 
        Dim index As Integer = Convert.ToInt32(e.CommandArgument)

        ' get the GridViewRow where the command is raised 
        Dim selectedRow As GridViewRow = DirectCast(e.CommandSource, GridView).Rows(index)

        ' for bound fields, values are stored in the Text property of Cells [ fieldIndex ] 

        Dim BrochureName As String = selectedRow.Cells(3).Text
        Dim BrochureId As String = selectedRow.Cells(1).Text
        Dim Productid As String = selectedRow.Cells(0).Text
        ' Dim MaintainOld As DataTable


        If e.CommandName = "AddToCart" Then

            dr(0) = BrochureName
            dr(1) = BrochureId
            dr(2) = Productid


            Cart.Rows.Add(dr)


        End If
        Session("NewUpdated") =  CartView
        requestCart.DataSource = CartView
     
        requestCart.DataBind()
        ' UpdatePanelRequestCart.Update()

    End Sub

Open in new window

0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 26114897
There appears to be some confusion retrieving the Cart variable from the Session in these lines:

       ElseIf Page.IsPostBack Then
            Cart = DirectCast(Session("NewUpdated"), DataTable)
        ElseIf Not (Session("shoppingSession") Is Nothing) Then
            Cart = DirectCast(Session("shoppingSession"), DataTable)
        End If

That logic doesn't make any sense.  If the page is posted back, you have the wrong session variable name.  If the page is not posted back (initial load), then the Session variable is never set, so that branch will never be reached.
0
 
LVL 1

Author Comment

by:SaraDob
ID: 26115003
I got you...The Session, Where i'm inserting is probably wrong.
I did the TxtBox retrieval from pageLoad.It is getting there On Is.Postback event but getting lost on when i'm putting back that session(ShoppingSession").
So now, either i have to call InsertrequestcartItems from pageLoad in IsPostBack event or
Reset the Session("Shoppingcart")...Which is what i'm unable to do...
What do you Say? any thoghts?? We are close to striking it...
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 26115094
I would say something more like this would work:

       ElseIf Page.IsPostBack Then
            Cart = DirectCast(Session("shoppingSession"), DataTable)
        End If
0
 
LVL 1

Author Closing Comment

by:SaraDob
ID: 31667808
You really helped me getting the facts! thanks for being ssooo patient.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month18 days, 6 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question