mathieu_cupryk
asked on
Web User Control Drop Down List does not show selected item
The form and behind the form code.
<td class="TicketLabel"><asp:L abel ID="lblType" runat="server" Text="Type:" Font-Bold="True"></asp:Lab el></td>
<td class="TicketLabel">
<KORE:uxLookupFieldTicketT ype runat="server" ID="uxLookupFieldTicketTyp e1"
KeyField="TicketType" ValueField="ID" />
</td>
protected void btnSaveExit_Click(object sender, EventArgs e)
{
// Instantiate business object
BLL.Ticket ticket = new BLL.Ticket();
// ticket.TicketType =
Response.Write (uxLookupFieldTicketType1. SelectedVa lue);
}
<td class="TicketLabel"><asp:L
<td class="TicketLabel">
<KORE:uxLookupFieldTicketT
KeyField="TicketType" ValueField="ID" />
</td>
protected void btnSaveExit_Click(object sender, EventArgs e)
{
// Instantiate business object
BLL.Ticket ticket = new BLL.Ticket();
// ticket.TicketType =
Response.Write (uxLookupFieldTicketType1.
}
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="uxLookupFieldTicketType.ascx.cs" Inherits="KORE.SIDWebClient.UI.Controls.uxLookupFieldTicketType" %>
<asp:DropDownList ID="LookupTypeTicketDropDown" AppendDataBoundItems="true" Width="200px" runat="server">
<asp:ListItem Value=""></asp:ListItem>
</asp:DropDownList><br />
<asp:RequiredFieldValidator id="CVLookupTypeTicketDropDown"
Text="(Required)"
InitialValue=""
ControlToValidate="LookupTypeTicketDropDown"
Runat="server" />
private string _keyField;
private string _valueField;
private string _defaultValue;
public uxLookupFieldTicketType()
{
}
protected void Page_Load(object sender, EventArgs e)
{
LookupTypeTicket lookup = new LookupTypeTicket();
this.LookupTypeTicketDropDown.Items.AddRange(lookup.getLookupListItemGroup(this.KeyField, this.ValueField));
ListItem selected = this.LookupTypeTicketDropDown.Items.FindByValue(this.DefaultValue);
this.LookupTypeTicketDropDown.SelectedIndex = this.LookupTypeTicketDropDown.Items.IndexOf(selected);
}
///////////////////////////////////////////////////////////////////////////////////////////
/// <summary>
///
/// </summary>
///
[Category("Data"), Description("Selected Index of the DropDownList"), Browsable(true)]
public int SelectedIndex
{
get
{
return LookupTypeTicketDropDown.SelectedIndex;
}
}
[Category("Data"), Description("Selected Text of the DropDownList"), Browsable(true)]
public string SelectedText
{
get
{
return LookupTypeTicketDropDown.SelectedItem.Text;
}
}
[Category("Data"), Description("Selected Valueof the DropDownList"), Browsable(true)]
public string SelectedValue
{
get
{
return LookupTypeTicketDropDown.SelectedValue;
}
}
/// <summary>
/// ////////////////////////////////////////////////////////////////////////////////////////
/// </summary>
[Category("Data"), Description("The dataset column that will be display field in the dropdown"), Browsable(true)]
public string KeyField
{
get
{
return _keyField;
}
set
{
_keyField = value;
}
}
[Category("Data"), Description("The dataset column that will be value field in the dropdown"), Browsable(true)]
public string ValueField
{
get
{
return _valueField;
}
set
{
_valueField = value;
}
}
public string DefaultValue
{
get
{
return _defaultValue;
}
set
{
_defaultValue = value;
}
}
}
}
dropdown.gif
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Can you show the return value of:
lookup.getLookupListItemGr oup(this.K eyField, this.ValueField)
what type are the objects and what is their value.
lookup.getLookupListItemGr
what type are the objects and what is their value.
ASKER
I forgot to put the IF (!postback)
ASKER
nice try.
ASKER
string val = (uxLookupFieldTicketType1.
Response.Write(val);
still giving me null