Click here to Skip to main content
15,889,651 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi
I got a combobox when I select it, the Grid view display the records of the selected item.
My combobox is bided to the database so as my gridview. now I want to have "All" option on combobox that will display every records in database in the same combobox that I have those option that display records that link with
1. is it possible to do that?
2.if yes, how must I add the"All"option on combobox
Posted

1 solution

if you use the property "AppendDataBoundItems" set to true, you can specify the ListItem in the aspx page. The ListItem taken from the database, will be added below. In this way you can add values ​​that are not present in the database.

ASP.NET
<asp:dropdownlist appenddatabounditems="true" ...="" xmlns:asp="#unknown">
    <asp:listitem text="All" value="" />
</asp:dropdownlist>
 
Share this answer
 
Comments
Mphirana 21-Jun-12 8:11am    
how do I bind my gridview in that item i just add
Mphirana 22-Jun-12 7:05am    
<telerik:RadComboBox ID="cmbPortfolio" runat="server" AutoPostBack="True"
AllowCustomText="True"
önselectedindexchanged="cmbPortfolio_SelectedIndexChanged" AppendDataBoundItems="True" >
<items>
<telerik:RadComboBoxItem runat="server" Text="All" Value="100" />


protected void cmbPortfolio_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
if (cmbPortfolio.SelectedValue== "100")
{
SqlConnection connections = new SqlConnection(Connection());

SqlCommand commands = new SqlCommand("SELECT costID,costGoal,priority,planned,achieved,costMotivation,costStartDate,costDueDate FROM Cost", connections);

SqlDataAdapter daimagess = new SqlDataAdapter(commands);

DataTable dt = new DataTable();

daimagess.Fill(dt);

gvCost.DataSource = dt;

//gvCost.DataBind();
}

my error
Both DataSource and DataSourceID are defined on 'ctl00'. Remove one definition.
cpsglauco 22-Jun-12 11:08am    
you don't have to rebind gridview with another data in cmbProtfolio_selectedindexchanged evetn. But you must use cmbProtfolio as parameter for datasource binded to gridview

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900