How to add a default item as 'N/A' to drop down list and set selected?
[sourcecode language="csharp"]
gnList.DataSourceID = "GNDS";
gnList.DataTextField = "Name";
gnList.DataValueField = "Id";
gnList.DataBind();
gnList.Items.Insert(0, new ListItem("N/A", "0"));
[/sourcecode]
Another way
[sourcecode language="csharp"]
gnList.Items.Add(new ListItem("N/A", "0"));
gnList.DataSourceID = "GNDS";
gnList.DataTextField = "Name";
gnList.DataValueField = "Id";
gnList.DataBind();
gnList.Items.FindByValue("0").Selected = true;
[/sourcecode]
Showing posts with label DropDownList. Show all posts
Showing posts with label DropDownList. Show all posts
Saturday, March 21, 2015
Friday, March 20, 2015
Static DropDownList in GridView
Displaying a DropDownList column in GridView and setting the selected item.
[sourcecode language="csharp"]
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Bind("Status") %>' autocomplete="off" Width="150">
<asp:ListItem Value="1">Enable</asp:ListItem>
<asp:ListItem Value="2">Disable</asp:ListItem>
<asp:ListItem Value="3">Delete</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
[/sourcecode]
[sourcecode language="csharp"]
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Bind("Status") %>' autocomplete="off" Width="150">
<asp:ListItem Value="1">Enable</asp:ListItem>
<asp:ListItem Value="2">Disable</asp:ListItem>
<asp:ListItem Value="3">Delete</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
[/sourcecode]
Subscribe to:
Posts (Atom)
How to enable CORS in Laravel 5
https://www.youtube.com/watch?v=PozYTvmgcVE 1. Add middleware php artisan make:middleware Cors return $next($request) ->header('Acces...
-
I have already written several posts regarding Android database applications. This post might be similar to those tuts. However this is more...
-
< Requirements Java Development Kit (JDK) NetBeans IDE Apache Axis 2 Apache Tomcat Server Main Topics Setup Development Environ...