I have a scenario in which i have a user control having a ASPxRadioButtonList, i have a data source bind to this list.
Now when i select some option in the ASPxRadioButtonList and on update button when i try to get the selected item, it returns null.
i used following code:
int id = ((ASPxRadioButtonList)ucPlannedRelease.FindControl("lstRdoTicketDetail")).Value.ToString();
Even i tried to create a function in the control and to get the select item but it always returns null.
I am unable to find where i am doing wrong
Related
I have an asp.net DropDownList that I use to filter a RadGrid. After the filter has been applied I can click on a row to edit the record on a separate page. I have a requirement to provide the ability, if the wrong row was selected, to return to the previous search page and display the same records with the same filter. I have taken care of the return and showing the same filtered records.
I also need to show the same value in the dropdown list that was chosen to create the filter. I am trying to do this using a session variable. The session variable gets created on the search click and I am trying to select the same item from the drop down using this code when the user returns to the search page.
string value = (Session["ComplaintType"] != null) ? Session["ComplaintType"].ToString() : String.Empty;
ddlComplaint.Items.FindByValue(value).Selected = true;
It is not working ant I get this error message: Object reference not set to an instance of an object.
Not sure why I am getting that error the string value is equal to the text value of the item selected from the Drop down??
I was able to solve this problem by setting the dropdownlist selected value in the BindDropDown method where I bind the database to the database. Once it was bound I could select a value from the database as the default value.
Is there a method of going about selecting items from a checked list box in coded ui when the exact text contained within the list box item will not be known until runtime? Perhaps a method of selecting a list box item at a certain index?..
I've tried using click list box at point (x,y) but whenever a list item is in its place it throws and error because it is in the way, And i cant try clicking the list box item itself as the full text it displays is a randomly generated ID and i am not sure if there is another method of finding items.
Another possibility would be passing in the text of the list box item to select at run time?
This is currently what I am trying to do in order to grab the control although it's throwing errors due to type mismatch
Managed to get it working with the following:
WinList uIItemList = UIMainwindowWindow.UIClbxSearchResultsWindow.UIClbxSearchResultsList;
WinCheckBox listItem = (WinCheckBox)uIItemList.Items[0];
listItem.Checked = true;
Just set the SelectedIndex property of the list box after its been populated. The below very simple example sets it to item 3 ( Zero based index)
lstBox.SelectedIndex = 2;
As per your comments, the same can still be achieved on checked list box with the below.
chkListBox.SelectedIndex = 2;
chkListBox.SetItemCheckState(2, CheckState.Checked);
Hope that helps.
I have an array of RadioButtonLists.
RadioButtonList[] r = new RadioButtonList[20];
On clicking a view button, my program creates a dynamic table and adds an image and a RadioButtonList to each cell:
tcell.Controls.Add(r[i])
On clicking a submit button, I’m trying to access the value of SelectedIndex on all RadioButtonLists; however, it’s showing up as null.
var value = r[i].SelectedValue;
I found some answers on how to get the value of RadioButtons created dynamically using .FindControl, but since my table is also dynamic, when I give Table1.rows, it results in null.
Dynamically created controls lose their state, when they are posted back, so you will have to re-create it yourself - outside the
if(!IsPostBack)
block in Page_Load (or somewhere similar).
I have a listview (in Details view) that is filled dynamically. I want to grab the text from the the first item in the listview.
This code doesn't work
lstSalesppl.Items[0].Selected = true;
string teamLeader = lstSalesppl.SelectedItems[0].Text;
I get an error on the second line: Invalid argument=Value of '0' is not valid for 'index' however the same code works in another method when the listview item is double clicked
Can anyone tell me what I'm doing wrong?
Thanks
try using
lstSalesppl.Items[0].Text
rather than
lstSalesppl.SelectedItems[0].Text;
lstSalesppl.SelectedItems may not be bound to the Selected attribute
ListView.SelectedItems Property
The SelectedItems property will not contain any items if the property is accessed before the ListView handle is created, which typically occurs when ListView is initially loaded for display in the form. You can check to see if the handle is created with the IsHandleCreated property. When the MultiSelect property is set to true, this property returns a collection containing the items that are selected in the ListView. For a single-selection ListView, this property returns a collection containing the only selected item in the ListView. For more information on the tasks that can be performed with the items in the collection, see ListView.SelectedListViewItemCollection.
We are using SharePoint 2010 Foundation.
We have an item in a list that is a dropdown with values from another list.
When we access the list as a SharePoint list it works fine, we can select a value, save the list, the next time we access the list the correct value is selected.
We have programmed a form that will updated the list. When we pull up the form, select a value and save it, we can see by accessing the list directly that the value has been saved.
However, when we pull up the form again it is the first item in the list that is selected. Have tried storing the selected value is a temp variable before binding the list but have not been able to get it to work. Anyone know how to fix this?
We found a solution.
The trick was to get the number that is the first part of the ToString of the SPListItem, before binding the list.
Then use that number to set the selected value after the list is bound
Parameters:
SPListItem currentItem, string fieldName
Code:
string selectedValue = currentItem[fieldName].ToString().Substring(0,1);
//... Bind list
ddlLookup.SelectedValue = selectedValue;