findcontrol in datagrid footer

R

Ruby

Hi All...

I have problem with web form datagrid:
I have 1 dropdownlist and 1 text box in datagrid footer. I want every time
index change in
dropdown list a value from database table stored in text box
Here some code:

<asp:TemplateColumn SortExpression="AccNo" HeaderText="Account No">
<ItemTemplate>
<asp:Label id=lblAccNo runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.AccNo") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:DropDownList id="cmbAccNoIns"
OnSelectedIndexChanged="AccNoInsIndexChange" AutoPostBack="true"
Runat="server"></asp:DropDownList>
</FooterTemplate>
<EditItemTemplate>
<asp:DropDownList id="cmbAccNo"
OnSelectedIndexChanged="AccNoIndexChange" AutoPostBack="True"
Runat="server"></asp:DropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="Descript" HeaderText="Description">
<ItemTemplate>
<asp:Label id=lblDescript runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Descript") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtDescriptIns" Width="215px"
Runat="server"></asp:TextBox>
</FooterTemplate>
<EditItemTemplate>
<asp:TextBox id=txtDescript Width="215px" Text='<%#
DataBinder.Eval(Container, "DataItem.Descript") %>' Runat="server">
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>

in codebehind:

Public Sub AccNoInsIndexChange(ByVal sender As Object, ByVal e As EventArgs)

Dim txtDescriptIns As TextBox = CType(FindControl("txtDescriptIns"),
TextBox) // Not found



Dim s As String = cmbDivision.SelectedValue + CType(sender,
DropDownList).SelectedValue

Dim dbAccess As New Pratama.AllClass

Dim sAccDesc(1) As String

sAccDesc = dbAccess.GetColumnSingleValue("Select MA_AccDesc From MST_COA
Where MA_Division+MA_AccNo = '" + s + "'")

txtDescriptIns.Text = sAccDesc(1) // Error since txtdescriptIns is Nothing

End Sub

why findcontrol method doesn't return any object? or is there any other trik
to to that?



Thank



Ruby
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top