NOMU26,
The Last Part of your Question: In the Item Template (not in edit mode) I show a label with the text needed. It is bound to the Description of the Expense Type in this instance.
Code Review:
First of all your Drop Down is in the Item Template instead of the Edit Template. Also you need to bind the data source and value in the HTML. See my code above. You don't need a drop down unless you are in edit mode, just use the label. You are replacing the TextBox with the DropDownList (sometimes I will even use both but that is another story...)
<asp:TemplateColumn HeaderText="Status">
<HeaderStyle Font-Bold="True" Font-Size="XX-Small" Width="60" Font-Name="verdana" Wrap="False"
HorizontalAlign="Center"></HeaderStyle>
<ItemStyle Font-Size="XX-Small" Font-Names="Arial"></ItemStyle>
<ItemTemplate>
<asp:Label id="Label3" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Status") %>' Visible="False" Font-Bold="True">
</asp:Label>
<asp

ropDownList ID="cboStatus" Runat="server"></asp

ropDownList>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="Textbox10" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Status") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
I don't normally fill the dropdownlist on the ItemBound event. The following would be how I set a listbox based on the entry in the text field.
<asp:TemplateColumn HeaderText="Client / City / State Notation">
<ItemTemplate>
<asp:Label id=lblClientCityState runat="server" Width="338px" Text='<%# DataBinder.Eval(Container, "DataItem.ClientCityStateNotation_VC") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id=txtClientCityStateEdit runat="server" Width="338px" Font-Size="10px" Font-Names="Arial" AutoPostBack="True" Text='<%# DataBinder.Eval(Container, "DataItem.ClientCityStateNotation_VC") %>' OnTextChanged="GetCustNameFiltered">
</asp:TextBox><BR>
<asp:ListBox id="lstClientCityStateEdit" runat="server" Width="338px" AutoPostBack="True" DataValueField="CustomerName_VC"
DataTextField="CustomerName_VC" OnSelectedIndexChanged="SetTextField" Rows="4"></asp:ListBox>
</EditItemTemplate>
</asp:TemplateColumn>
Sub GetCustNameFiltered(ByVal sender As System.Object, ByVal e As System.EventArgs)
Try
Dim strName As String
strName = CType(Me.dgDetail.Items.Item(dgDetail.EditItemIndex).FindControl("txtClientCityStateEdit"), TextBox).Text
Dim sb As SQLBean = New SQLBean
Dim strSQL As String
If strName = "" Then
strSQL = "SELECT DISTINCT TOP 100 PERCENT CustomerName_VC FROM dbo.ks_Customer_T ORDER BY CustomerName_VC"
Else
strSQL = "SELECT DISTINCT TOP 100 PERCENT CustomerName_VC FROM dbo.ks_Customer_T WHERE CustomerName_VC LIKE '%" & strName & "%' ORDER BY CustomerName_VC"
End If
ds = sb.getClients(strSQL)
Dim lstClient As ListBox
lstClient = CType(Me.dgDetail.Items.Item(dgDetail.EditItemIndex).FindControl("lstClientCityStateEdit"), ListBox)
lstClient.DataSource = ds.Tables(0).DefaultView
lstClient.DataBind()
Catch ex As Exception
lblError.Text = Trim(lblError.Text & " A problem was found loading the Customer List for Editing. Please try again.")
End Try
End Sub
Sub SetTextField(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim lstClient As ListBox
lstClient = CType(Me.dgDetail.Items.Item(dgDetail.EditItemIndex).FindControl("lstClientCityStateEdit"), ListBox)
Dim txtClient As TextBox
txtClient = CType(Me.dgDetail.Items.Item(dgDetail.EditItemIndex).FindControl("txtClientCityStateEdit"), TextBox)
txtClient.Text = lstClient.SelectedItem.Text
End Sub
I hope this helps and points you into the right direction.
Hope everyone is having a great day!
Thanks - Jennifer