I have a RadComboBox that allows for custom searching for about 1500 records. Once one is selected the User control changes accordingly. If I were to want to select a new record, the selected record is the only record that displays and when you type in the search field, nothing is found either.
However, if you select a record, do what you need then click the drop down then click off it then click on it again, it resets itself as desired. How can I make it so the drop down list populates itself on the initial click?
Probably you are losing the datasource.
On the SelectedIndexChange event, you can repopulate the datasoure and set currently selected value from arguments that are passed to this event.
So in a pseudocode it would look like:
procedure OnSelectedIndexChanged(object sender, SelectedIndexChangedEventArgs e)
{
var selectedValue = e.Value;
(sender as RadComboBox).DataSource = YourMethodToGetDatasource();
(sender as RadComboBox).DataBind();
(sender as RadComboBox).SelectedValue = selectedValue;
}
and yes i know currently pseudo code doesn't look so pretty but of course you will need to use the id of your control in place of (sender as RadComboBox).
If someone know a better method for this i would be glad to gain this knowledge :)
Related
I am using Objectlistview in my WFA to create a chekedlistbox.
I want to have a button called "Select all" that the user can click on it and all the rows are selected just by one click.
I have been using the following code which works and all the checkboxes will be selected
private void btnSelectallModule_Click(object sender, EventArgs e)
{
foreach (ListViewItem item in dataListView1.Items)
{
item.Checked = true;
}
}
The problem is that when I check all the items using this button then I hover over each item it will be unchecked automatically without even clicking on that item, which is so weird because I did not intend to do that in the code.
Does anyone know what is going on and how can I fix this?
Thanks
In general do NOT manipulate the ListViewItem objects when working with ObjectListView.
There is a Method dataListView1.CheckAll() that will do exactly what you are trying to do - check all items. Using that method will properly set the internal check states of the OLV control and prevent them from getting visually unchecked when the view refreshes (when hovering the mouse over items).
I have 2 databounded dropdownlist. They have the same value(all months).
I want that, if a user choose (in the first Dropdown) for example april then the second Dropdown should jump automatically to April.
The only thing I could think of was:
protected void ddMonthfrom_SelectedIndexChanged(object sender, EventArgs e)
{
ddMonthfrom.SelectedItem.Text = ddMonthto.SelectedItem.Text;
}
It does not work. When I click on April the second Dropdown does not Change.
try ddMonthto.SelectedValue = ddMonthfrom.SelectedItem.Value;
OnFristDropDownSelectedIndexChange (ddMonthfrom)
Set the value of the Second DropDown (ddMonthto).
If they are the same values in both Drop Downs then remove the text portion
ddMonthfrom.SelectedItem = ddMonthto.SelectedItem;
Try:
ddMonthfrom.SelectedIndex = ddMonthfrom.FindStringExact(ddMonthto.Text);
This should also work if the comboBox ddMonthto doesn't have a DataSource.
Notes:
You can also use .SelectedItem.ToString() instead of .Text, while .SelectedItem.Text isn't correct.
If you populate your comboBox using a datasource, you can just use the same datasource for both comboBoxes, and the same item should be selected automatically.
Hope that helps :)
I have an aspx webform written in C#. This page has three dropdown boxes. These dropdown boxes load values for Department, Site and Team from the corresponding tables.
Based upon logged in user's permissions an item will be preselected from these three dropdown boxed during page load. On the same page I have a gridview whose data should be filtered based upon the selected values of these three dropdown boxes.
The sql for the gridview's data source should be something like this: select * from abc where Department = <selecteditem> and Site = <selecteditem> and Team = <selecteditem>.
I have a button on the page named as Apply Filter which takes the selected items and constructs the sql, and the gridview is populated fine. However I want this filtration to happen automatically during page load event without anyone manually clicking the button after the page load.
I've tried to execute the button click event during the page event, but the filtration doesn't happen. Please let me know the best way to achieve this.
Thanks
I think you have to do like this
`protected void DropDownBoxDepartment_SelectedIndexChanged(object sender, EventArgs e)
{
// Here gives the DataSource for the DataGrid View for the DEPARTMENTSelection
}
protected void DropDownBoxSite_SelectedIndexChanged(object sender, EventArgs e)
{
// Here gives the DataSource for the DataGrid View for the SITE Selection (or Department and Site Selection whatever you want)
}
protected void DropDownBoxTeam_SelectedIndexChanged(object sender, EventArgs e)
{
// Here gives the DataSource for the DataGrid View for the TEAM Selection (or Department, Site and Team Selection whatever you want)
}`
Hope this Code Helps You....If I understand your question well.
In the Page_load event do the below:
Get the user name of the user who has logged in currently by:
String name = System.Web.HttpContext.Current.User.Identity.Name;
I hope you could figure out the permissions levels of the user with the user name.
According the permission level set the desired selected index value of your three different drop down list like below (sample)
departmentDropDownList.SelectedIndex=1;
After setting the desired value for all the three drop down do the Grid DataBind().
NOTE: I'm pretty sure you would not require this automated GridView DataBind to happen for all the post back. If that is true then put the above Page_Load code within the below condition so that this automated filtering happens only for the initial page load.
if(!IsPostBack){
}
I have two Comboboxes where the second one is dependent upon the first one.
When the SelectedIndexChanged event of the first Combobox fires then the second Combobox will be enabled.
After the event, the second Combobox is enabled but I cannot select the ComboBox item.
EDIT
I use Dev express Tools
First Combo I load in Page_Load Event
I use Server Side code:
protected void ASPxComboModule_SelectedIndexChanged(object sender, EventArgs e)
{
LoadSecondCombo();
LoadSecondCombo.Focus();
}
There is no problem in loading, but I'm unable to select 2nd combo item.
What do this do: LoadSecondCombo(); I assume it returns an instance of the control. Where does it set combo.Enabled at?
LoadSecondCombo(); LoadSecondCombo.Focus();
look like method that reference your comboBox and Load it.
When you want to focus LoadSecondCombo should ne an instance of Combo Box. I think it is not and so your combo is not selected.
Can you try going back a bit and look at the Id of combo Box (if it in a composit control like DataGrid / View you will have to do a FindControl) and then focus. I mean typing
comboBtn1.Focus();
Now if that works then you know that your control can be found. In that case mofidify the LoadSescondCombo() to return an instance of combo button if it is not doing so already.
then create a reference to that combobutton by
ComboButton cbtn = LoadSecondCombo(); and
cbtn.Focus();
I have a pretty simple form with a listbox, a text box, and two buttons.
The list box items are populated from a sql database table. The user may chose to select one or multiple items from the listbox.
The text box is used to write more details about the items in the listbox. One button can then be clicked to update another database table with these details.
I want to make it where if any items are selected from the listbox, those contents are automatically copied into the text box field on the fly as they are selected.
Is this possible?
I've been able to make this happen on the button click event - just not on the fly as they are selected. I want it to occur before the additional details are being sent to the database
I've also tried using several different listbox events, but have been unable to obtain the results I am looking for.
Any suggestions?
try this out
you will have to handle the SelectedIndexChanged event on the listbox.
here is an example with example controls.
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
textBox1.Text = "";
foreach (string nextitem in listBox1.SelectedItems)
{
textBox1.Text += nextitem + " ";
}
}
im not too sure HOW you want the text to appear in the textbox so that would be up to you in the foreach loop.
yes, the SelectedIndexChanged event fires on every selection change, and you can concatenate together the items in the listbox. But if you are talking the description that's not visible too, you need to store the description in each listboxitem tag property, and in your code retrieve the description from there.