FINDCONTROL PROBLEM

Discussion in 'ASP .Net Datagrid Control' started by in da club, Mar 29, 2007.

  1. in da club

    in da club Guest

    I have a datagrid and save button in my page.. when i click save button it
    doesnt get the text box values. What can be the problem ?



    <asp:DataGrid id="DataGrid_telefon"
    OnDeleteCommand="DataGrid_telefon_OnDeleteCommand"
    OnItemDataBound="DataGrid1_OnItemDataBound" style="Z-INDEX: 101; LEFT: 48px;
    POSITION: absolute; TOP: 112px"
    runat="server" AllowPaging="True" AutoGenerateColumns="False"
    Font-Size="Medium">
    <Columns>
    <asp:TemplateColumn HeaderText="Sil">
    <ItemTemplate>
    <!--<asp:Button id="Button1" CommandName="Delete" runat="server"
    Text="Sil" Width="32px"></asp:Button>-->
    <asp:placeHolder Runat=server ID ="plhDelete"></asp:placeHolder>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn Visible="False" HeaderText="id">
    <ItemTemplate>
    <asp:TextBox id=txyorum runat="server" Text='<%#
    DataBinder.Eval(Container, "DataItem.yorum") %>' Width="24px"
    ReadOnly="True" Font-Size="XX-Small" Visible="False">
    </asp:TextBox>
    </ItemTemplate>


    <asp:Button id="Kaydet" style="Z-INDEX: 101; LEFT: 600px; POSITION:
    absolute; TOP: 596px" runat="server"
    Text="Kaydet" Width="88px"></asp:Button>

    in onclick event for save button

    Private Sub Kaydet_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles Kaydet.Click

    Dim strQuery As String

    Dim dgItem As DataGridItem

    'SqlConn.Open()

    Dim Marka As String

    For Each dgItem In DataGrid_telefon.Items

    Dim txtDesc As TextBox = _

    CType(dgItem.Cells(1).FindControl("txtyorum"), TextBox)


    Dim item As Integer

    strQuery = "I" & txtDesc.ID & txtDesc.Text.ToString



    Response.Write(strQuery)





    Next

    End Sub
    in da club, Mar 29, 2007
    #1
    1. Advertising

  2. in da club

    Teemu Keiski Guest

    Hi,

    it doesn't give you the value that was databound to it? Is it empty value or
    what?


    --
    Teemu Keiski
    AspInsider, ASP.NET MVP
    http://blogs.aspadvice.com/joteke
    http://teemukeiski.net



    "in da club" <xx> wrote in message
    news:...
    > I have a datagrid and save button in my page.. when i click save button it
    > doesnt get the text box values. What can be the problem ?
    >
    >
    >
    > <asp:DataGrid id="DataGrid_telefon"
    > OnDeleteCommand="DataGrid_telefon_OnDeleteCommand"
    > OnItemDataBound="DataGrid1_OnItemDataBound" style="Z-INDEX: 101; LEFT:
    > 48px; POSITION: absolute; TOP: 112px"
    > runat="server" AllowPaging="True" AutoGenerateColumns="False"
    > Font-Size="Medium">
    > <Columns>
    > <asp:TemplateColumn HeaderText="Sil">
    > <ItemTemplate>
    > <!--<asp:Button id="Button1" CommandName="Delete" runat="server"
    > Text="Sil" Width="32px"></asp:Button>-->
    > <asp:placeHolder Runat=server ID ="plhDelete"></asp:placeHolder>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > <asp:TemplateColumn Visible="False" HeaderText="id">
    > <ItemTemplate>
    > <asp:TextBox id=txyorum runat="server" Text='<%#
    > DataBinder.Eval(Container, "DataItem.yorum") %>' Width="24px"
    > ReadOnly="True" Font-Size="XX-Small" Visible="False">
    > </asp:TextBox>
    > </ItemTemplate>
    >
    >
    > <asp:Button id="Kaydet" style="Z-INDEX: 101; LEFT: 600px; POSITION:
    > absolute; TOP: 596px" runat="server"
    > Text="Kaydet" Width="88px"></asp:Button>
    >
    > in onclick event for save button
    >
    > Private Sub Kaydet_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles Kaydet.Click
    >
    > Dim strQuery As String
    >
    > Dim dgItem As DataGridItem
    >
    > 'SqlConn.Open()
    >
    > Dim Marka As String
    >
    > For Each dgItem In DataGrid_telefon.Items
    >
    > Dim txtDesc As TextBox = _
    >
    > CType(dgItem.Cells(1).FindControl("txtyorum"), TextBox)
    >
    >
    > Dim item As Integer
    >
    > strQuery = "I" & txtDesc.ID & txtDesc.Text.ToString
    >
    >
    >
    > Response.Write(strQuery)
    >
    >
    >
    >
    >
    > Next
    >
    > End Sub
    >
    >
    >
    >
    Teemu Keiski, Apr 9, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jaime

    FindControl problem

    Jaime, May 20, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    670
    Jaime
    May 20, 2005
  2. =?Utf-8?B?dHBhcmtzNjk=?=

    ItemCreated FindControl problem c#

    =?Utf-8?B?dHBhcmtzNjk=?=, Jun 16, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    6,509
    =?Utf-8?B?QkVMSVVT?=
    Jun 16, 2005
  3. Arjen

    Findcontrol problem

    Arjen, Oct 17, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,033
    Scott Allen
    Oct 18, 2005
  4. ThunderMusic
    Replies:
    2
    Views:
    412
    ThunderMusic
    Oct 9, 2006
  5. Terry

    problem with FindControl

    Terry, Feb 15, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    580
    Terry
    Feb 15, 2007
Loading...

Share This Page