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>
<aspropDownList id="cmbAccNoIns"
OnSelectedIndexChanged="AccNoInsIndexChange" AutoPostBack="true"
Runat="server"></aspropDownList>
</FooterTemplate>
<EditItemTemplate>
<aspropDownList id="cmbAccNo"
OnSelectedIndexChanged="AccNoIndexChange" AutoPostBack="True"
Runat="server"></aspropDownList>
</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
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>
<aspropDownList id="cmbAccNoIns"
OnSelectedIndexChanged="AccNoInsIndexChange" AutoPostBack="true"
Runat="server"></aspropDownList>
</FooterTemplate>
<EditItemTemplate>
<aspropDownList id="cmbAccNo"
OnSelectedIndexChanged="AccNoIndexChange" AutoPostBack="True"
Runat="server"></aspropDownList>
</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