<EditFormSettings EditFormType="Template">
<FormTemplate>
<table width="100%">
<tr>
<td>
<asp:Label ID="lblUserName" runat="server" Text="User Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtUserName" runat="server" Text='<%# Bind("Username") %>'></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblInitialPwd" runat="server" Text="Initial Password"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtInitialPwd" runat="server" Text='<%# Bind("InitialPassword") %>'></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblUserpassword" runat="server" Text="User Password"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtUserpassword" runat="server" Text='<%# Bind("UserPassword") %>'></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblEmail" runat="server" Text="E-mail"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtEmail" runat="server" Text='<%# Bind("Email") %>'></asp:TextBox>
</td>
</tr>
<tr>
<td width="10%">
</td>
<td width="90%">
<table>
<tr>
<td><span style="font-weight:bold; font-size:10pt"></span>
<asp:Label ID="lblAccountNumber" runat="server" Text='<%# Bind("AccountNumber") %>' Font-Bold="true" Font-Size="10"></asp:Label><br />
<asp:ListBox ID="lbAllAccountNumbers" DataSourceID="objAllAccountNumbers" runat="server" Width="200" Height="200"></asp:ListBox>
<asp:Button ID="btnSelect" runat="server" Text=">" />
<asp:Button ID="btnUnselect" runat="server" Text="<" />
<asp:ListBox ID="lbAvailableAccountNumbers" DataSourceID="objAllAccountNumbers" runat="server" Width="200" Height="200">
</asp:ListBox>
</td>
</tr>
</table>
</td>
</tr>
</table>
</FormTemplate>
</EditFormSettings>
I have two SqlDatSource 1 datasource for grid and one for ListBox.
I set up a Datakey name For the grid which will server as the parameter for the ListBox SqlDataSource.
I tried setting up the parameter for ListBox Datasource from Grid ItemDataBound but when doing Find Control method returns null.
below is my code behind
if
(e.Item is GridEditFormItem)
{
ListBox lbAllAccountNumbers = (ListBox)e.Item.FindControl("lbAllAccountNumbers");
SqlDataSource ds = (SqlDataSource)lbAllAccountNumbers.DataSource;
ds.SelectParameters[
"@LoginId"].DefaultValue = grdAffiliate.Items[e.Item.ItemIndex].OwnerTableView.DataKeyValues[e.Item.ItemIndex]["LoginId"].ToString();
lbAllAccountNumbers.DataSource = ds;
lbAllAccountNumbers.DataBind();
}
lbAllAccountNumbers is getting null value