D
drdave
All is working well for my dropdown/datagrid except I cannot figure out
how to set my ddl selected index when the value is blank/null.
ie before edit mode the lblVariation text value is blank..
This routine sets the value strVariation
Sub dgMinimumWage_EditRow(sender as Object, e As
DataGridCommandEventArgs)
strVariation = CType(E.Item.FindControl("lblVariation"), Label).Text
dgMinimumWage.EditItemIndex = e.Item.ItemIndex
dgMinimumWageBindData()
End Sub
This routine works great when I've got a value.
Public Sub SetVariationDropDownIndex(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim ed As System.Web.UI.WebControls.DropDownList
ed = sender
If strVariation Is "" THEN
ed.SelectedIndex = 0
Else
ed.SelectedIndex = ed.Items.IndexOf(ed.Items.FindByText(strVariation))
End If
End Sub
On the html side I have this..
<asp:TemplateColumn HeaderText="Variation/Condition">
<itemtemplate>
<asp:label ID="lblVariation" Text='<%#
DataBinder.Eval(Container.DataItem, "english_text") %>' Runat="server"
/>
</ItemTemplate>
<edititemtemplate>
<asp:dropdownlist id="ddlVariations" runat="server"
DataTextField="english_text" DataValueField="minimum_wage_variation_id"
DataSource="<%# GetVariations() %>"
OnPreRender="SetVariationDropDownIndex" Width="450">
<asp:listitem Value="0">dave</asp:listitem>
</asp:dropdownlist>
</EditItemTemplate>
</asp:TemplateColumn>
However the selected value in the dropdown is always the first
variation in the datset..
Am I able to do this at runtime or maybe I should try and add a blank
value to the dataset??
Any suggestions??
Dave
how to set my ddl selected index when the value is blank/null.
ie before edit mode the lblVariation text value is blank..
This routine sets the value strVariation
Sub dgMinimumWage_EditRow(sender as Object, e As
DataGridCommandEventArgs)
strVariation = CType(E.Item.FindControl("lblVariation"), Label).Text
dgMinimumWage.EditItemIndex = e.Item.ItemIndex
dgMinimumWageBindData()
End Sub
This routine works great when I've got a value.
Public Sub SetVariationDropDownIndex(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim ed As System.Web.UI.WebControls.DropDownList
ed = sender
If strVariation Is "" THEN
ed.SelectedIndex = 0
Else
ed.SelectedIndex = ed.Items.IndexOf(ed.Items.FindByText(strVariation))
End If
End Sub
On the html side I have this..
<asp:TemplateColumn HeaderText="Variation/Condition">
<itemtemplate>
<asp:label ID="lblVariation" Text='<%#
DataBinder.Eval(Container.DataItem, "english_text") %>' Runat="server"
/>
</ItemTemplate>
<edititemtemplate>
<asp:dropdownlist id="ddlVariations" runat="server"
DataTextField="english_text" DataValueField="minimum_wage_variation_id"
DataSource="<%# GetVariations() %>"
OnPreRender="SetVariationDropDownIndex" Width="450">
<asp:listitem Value="0">dave</asp:listitem>
</asp:dropdownlist>
</EditItemTemplate>
</asp:TemplateColumn>
However the selected value in the dropdown is always the first
variation in the datset..
Am I able to do this at runtime or maybe I should try and add a blank
value to the dataset??
Any suggestions??
Dave