I am using a WebDropDown with a WebDataGrid template. I have 3 columns in the grid ("Recnum", "Name" and "Details")
When an item in the WebDataGrid is selected, the WebDropDown displays the "Name", and I 'think' I am setting the Value to "Recnum" using the following Code:
dd.set_currentValue(rowid,
true);
dd._elements[
"Input"].value = rowName;
"Input"].focus();
dd.closeDropDown();
}
args.set_cancel(
However, when I try to access the values in my code behind, the SelectedItem properties, SelectedValue, etc., are all empty or nothing:
Dim
myRecnum As Guid = New Guid(webDropDown1.SelectedValue())
While I want the user to see the "Name", I need to use the "Recnum" value. How do I access this?
Hi Maya,
In the same fashion, I have a webdropdown with a webdatagrid itemtemplate
I need to set the webdropdown displayed value and template selected row at page load and I tried this :
wddMissionType.Items[0].Value = View_StaffMissions.MissionType;wddMissionType.CurrentValue = View_StaffMissions.MissionType;
In that case, there is no value displayed in the webdropdown and no selected item in the webdatagrid template, which is not the behavior one can expect
Could you please elaborate on these properties and how to access these fields at page load?
I've had no lock so far at trying other alternatives depicted in this forum, so I'm stuck there and it is blocking...
Thanks for your support!
Hello lorettac242 ,
I'm juts following up to see if you might need further assistance with this issue.
If so please let me know.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://ko.infragistics.com/support
Thank you for your clarification.
What you’re trying to implement is something similar to one of the samples in the samples browser:
http://samples.infragistics.com/aspnet/Samples/WebDropDown/Display/Templates/Default.aspx?cn=drop-down&sid=65cf1383-7ad7-4e9d-8372-b3fd4c0ea155
Because of the fact that you’re using a template and canceling the SelectionChanging event of the WebDropDown it’s expected that the SelectedItem/SelectedValue in the code behind would be null. This is so because when you cancel the Selection changing event no value is set to the selected value/item.
For that reason you manually set the currentValue property in the JS so that when you select a value from the grid this value would be set to the DD.
Here’s a possible solution for your scenario. Since the drop down contains only 1 item and that item is the WebDataGrid you can set the value of that item manually to the id column you need.Example:
var rowId = args.getSelectedRows().getItem(0).get_cell(0).get_text();
dd.get_items().getItem(0).set_value(rowId);
And from the code behind you can get that value. As for the text you can access the CurrentValue.Example:
protected void btn1_Click(object sender, EventArgs e)
{
var value = ddCustomTemplateGrid.Items[0].Value;
var shownText = ddCustomTemplateGrid.CurrentValue;
I’m attaching a sample for your reference. Please let me know if you have any questions or concerns regarding this.
The sample you referenced only sets one property in the webdropdown, which is the display property.
I have a multiple column databound webdatagrid template in a webdropdown. When the use selects an item in the webdatagrid, I want to display one of the values ("Name"), which is working; and set the 'value' of the webdropdown to another ("Recnum"), which I am not sure is working correctly. The code that I am using for this was in my original post.
When the user clicks a button on the page, I need to access the value property of the webdropdown, which should be the ("Recnum"), so that I can use it as a reference for something else. It is this server-side code that is not working.
Basically, I want to take two of the values/text columns from the webdatagrid, and use them for the 'selecteditem' value and text properties in the wegdropdown, so that I can access them later in server-side code.
I hope this makes things a little clearer.
Thank you for posting in our forum.
The currentValue represents only the value that will be displayed. It’s the value in the input box of the dropdown control so changing it would not affect the server side as explained in our online documentation:
http://help.infragistics.com/NetAdvantage/ASPNET/2011.1/CLR4.0/?page=WebDropDown~Infragistics.Web.UI.WebDropDown~currentValue.html
Since I’m not sure of what your particular scenario is and what kind of end result you’re expecting it would be very helpful if you could elaborate on that. If you have a reference free sample that you could provide it would also be very helpful so that I can better understand your scenario and help you in batter manner.
Thank you for your cooperation regarding this. I’m looking forward to your reply.