Re: Cannot get text value from editor in gridview

  •  04-23-2009, 5:00 AM

    Re: Cannot get text value from editor in gridview

    Hi mstrsftwr,
     
    Try this example please:
     
    ---------------------------------------------------->

    <%@ Page Language="VB" %>
    <%@ Import Namespace="System.Data" %>
    <%@ Register Namespace="CuteEditor" Assembly="CuteEditor" TagPrefix="CE" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">
        Private Function CreateDataSource() As ICollection
            Dim dt As New DataTable()
            Dim dr As DataRow
            dt.Columns.Add(New DataColumn("IntegerValue", GetType(Int32)))
            For i As Integer = 0 To 1
                dr = dt.NewRow()
           
                dr(0) = i
                dt.Rows.Add(dr)
            Next
            Dim dv As New DataView(dt)
            Return dv
        End Function
        Private Sub Page_Load(ByVal sender As [Object], ByVal e As EventArgs)
            If Not IsPostBack Then
                GridView1.DataSource = CreateDataSource()
                GridView1.DataBind()
           
            End If
        End Sub
        Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
            If e.CommandName = "show" Then
                Dim show As Button = DirectCast(e.CommandSource, Button)
                Dim row As GridViewRow = DirectCast(show.Parent.Parent, GridViewRow)
                Dim editor1 As CuteEditor.Editor = DirectCast(row.FindControl("editor1"), CuteEditor.Editor)
                label1.Text = editor1.Text
            End If
        End Sub
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
         <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowCommand="GridView1_RowCommand">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <CE:Editor ID="editor1" runat="server">
                            </CE:Editor>
                            <asp:Button ID="button1" runat="server" Text="show" CommandName="show" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="IntegerValue" />
                </Columns>
            </asp:GridView>
            <asp:Label ID="label1" runat="server"></asp:Label>
        </form>
    </body>
    </html>
    ---------------------------------------------------->
     
     
    Regards,
     
    ken
View Complete Thread