User Profile & Activity

Douglas Badin Member
Page
of 11

Hi,

That is working for me.

Thanks,

Doug

Hi,

One problem with the code is eventually with different values it displays nothing which can be corrected by setting the values to display with style.display = "inline".

if (RowValue != WebComboValue)
{
	Row.RowElement.style.display = "none";
}
else
{
	Row.RowElement.style.display = "inline";
}

 

Now the next step is I want to filter based on the [Roles].[DepartmentId] column.

1. It probably needs to be added to the SqlDataSource2 SelectCommand.

<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:SqlSampleConnection %>"
    SelectCommand="SELECT [RoleId], [RoleName], [DepartmentId] FROM [Roles]"></asp:SqlDataSource>

2. I do not want [Roles].[DepartmentId] to be displayed as a column in the DropDown

 

How do I reference the [Roles].[DepartmentId] Value in the OnEnterEditMode Event so I can Filter by it?

 

Thanks,

Doug

Hi Hans,

I will try it and let you know the results.

Thanks,

Doug

Hello,

Is your server still having problems?  (Other people are getting responses.)

Since you already replied about server problems, does that mean I dropped out of your To Do queue?

Have you done any investigation prior to this reply?

Please respond.

Thanks,

Doug

Hi,

How do I filter the List Items in the Unbound WebCombo?

I tried to use the WebCombo Client Side Method SetAdditionalFilters in the WebGrid ClientSideEvent OnEnterEditMode based on a value in the row but on the first time a row is selected it does not filter and on subsequent rows selected nothing is in the Drop Down List.

I modified the last code you supplied.

<ClientSideEvents
	OnEnterEditMode="WebGrid1_OnEnterEditMode"
/>
<script language="javascript" type="text/javascript">

	function WebGrid1_OnEnterEditMode(controlId, TableName, editObject)
	{
		var _WebGrid = ISGetObject(controlId);
		var _WebGridCell = editObject.ToCellObject();
		if (_WebGridCell.Name == "Roles")
		{
			var _WebCombo = editObject.element;
			var FilterValue_String ;
			var EmployeeID_String = _WebGridCell.Row.GetCell("EmployeeID").Value
			if (true)
			{
				switch (EmployeeID_String)
				{
					case "1":
						FilterValue_String = "1";
						break;
					default:
						FilterValue_String = "2";
				} 
				_WebCombo.SetAdditionalFilters("[RoleId] = " + FilterValue_String);
			}
			else
			{
				switch (EmployeeID_String)
				{
					case "1":
						FilterValue_String = "Research Staff";
						break;
					default:
						FilterValue_String = "Research Manager";
				}
				_WebCombo.SetAdditionalFilters("[RoleName] = " + "'" + FilterValue_String + "'");
			}
			_WebCombo.SetText(_WebGridCell.Text, true);
		}
		return true;
	}

</script>

Please see attached screenshots and code.

Thanks,

Doug

Hi,

Thanks, you anticipated my next question.  When I was doing testing, the example UsingWebComboNETwithMultipleSelection you provided, worked and mine did not.  I had simplified mine to mimic UsingWebComboNETwithMultipleSelection and mine still had a problem.  I was beginning to think it was database related.

My actual application uses varchar and it works okay when I just put in the BoundMode="ForceUnbound".  My sample was just simplified and modified to use the Northwind.mdf so you could reproduce the problem.  As chance would have it I picked a column of datatype nchar which ends up padding the Text with spaces as you explained.

Thanks,

Doug

Hi,

Per your instructions I got it to check intialized values by adding BoundMode="ForceUnbound" to WebCombo.LayoutSettings but that revealed a new problem.

<LayoutSettings
	ComboMode="SingleColumn"
	TextBoxMode="ReadOnly"
	BoundMode="ForceUnbound"
>

For the initialized values, when they are unchecked in the DropDown they are not removed from the TextBox.  See attached screen shots.

For new checked items, they are added and removed as unchecked.

What else do I need to do?

 

Thanks,

Doug

Hi,

I did not include my DataSets for the App_Code directory because I did not know the Web.config connectionString you would be using to connect to the Northwind Database.

I did not realize when I said in my first posting "A DataSet for the Tables Shippers and Region would need to be created." that you would not know how to create one or that your colleagues did not know how to either or would not help you.  You should have let me know in your first reply.

I assumed someone at Intersoft would know how to create a DataSet because they are used in the Intersoft ASP.NET Samples Projects.

Since the Regions table is in the SQL Northwind.mdf and not in Northwind.mdb you will need to use the SQL Database.  This can be identified by it's file extension of .mdf, not .mdb.

For instance, the Web.config in the WebGrid "C# Samples (Visual Studio 2010 Solution)" has the following SqlNorthwindConnectionString connectionString.

<add name="SqlNorthwindConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Northwind.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient"/>

Like the WebGrid "C# Samples (Visual Studio 2010 Solution)" you will have to have your Northwind.mdf and Northwind_log.ldf files in the App_Data Directory.

Next you need to create the DataSets in the App_Code directory.

Inspecting each ISDataSource.SchemaName you will find the names of the DataSet to use. 

<ISDataSource:ISDataSource
	ID="Shippers_ISDataSource"
	runat="server"
	SchemaName="dsNorthwindShippers"
<ISDataSource:ISDataSource
	ID="Region_ISDataSource"
	runat="server"
	SchemaName="dsNorthwindRegion"

For my sample you need to create the following DataSets:

- dsNorthwindShippers
- dsNorthwindRegion

If you have problems following my instructions on how to create a DataSet there are many resources typing “visual studio create dataset” into Google which returns links to MSDN How Tos, YouTube Videos and other content.

- http://msdn.microsoft.com/en-us/library/04y282hb.aspx
- http://www.youtube.com/watch?v=3Pbj7pRcu4I

To create DataSet using Visual Studio 2010: (It is slightly different for Visual Studio 2012)

For dsNorthwindShippers:

- Select the App_Code directory in the Solution Explorer
- Right Click App_Code
- Select Add New Item
- Select DataSet
- Enter dsNorthwindShippers for the Name
- Click Add Button
- Go to Server Explorer
- Expand Data Connections
- Expand you Northwind Connection
- Expand Tables
- Drag Shippers onto the Dataset Designer
- Save

For dsNorthwindRegion:

- Select the App_Code directory in the Solution Explorer
- Right Click App_Code
- Select Add New Item
- Select DataSet
- Enter dsNorthwindRegion for the Name
- Click Add Button
- Go to Server Explorer
- Expand Data Connections
- Expand you Northwind Connection
- Expand Tables
- Drag Region onto the Dataset Designer
- Save


If you have problems implementing my instructions, you are really going to have to ask your boss for help and direction.

 

Doug

Remember this is in a WebGridRow.

Apparantly the Values and Text are loading but the boxes are not checked.

I can load them Server Side in WebGrid OnIntializeRow:

	protected void _WebGrid_InitializeRow(object sender, RowEventArgs e)
	{
		if (e.Row.Table.Name == "Shippers")
		{
			if (e.Row.Type == RowType.Record)
			{
				WebGridCellCollection _WebGridCellCollection = e.Row.Cells;

				DataRowView _DataRow = e.Row.DataRow as DataRowView;

				Int32 ShipperID_Int32 = Convert.ToInt32(_DataRow["ShipperID"].ToString());
				String CompanyName_String = _DataRow["CompanyName"].ToString();
				
				WebGridCell Regions_WebGridCell = (WebGridCell)e.Row.Cells.GetNamedItem("Regions_WebGridColumn");


				switch (ShipperID_Int32)
				{
					case 1:
						Regions_WebGridCell.Text = "Eastern";
						Regions_WebGridCell.Value = "1";
						break;
					case 2:
						Regions_WebGridCell.Text = "Eastern; Western";	//"Western";	//"Eastern; Western"
						Regions_WebGridCell.Value = "1;2";				//"2";			// "1;2"
						break;
					case 3:
						Regions_WebGridCell.Text = "Northern";
						Regions_WebGridCell.Value = "3";
						break;
				}
			}
		}
	}

This is confirmed client side with WebCombo OnShowDropDown:

<script language="javascript" type="text/javascript">
	function Regions_WebCombo_OnShowDropDown(controlId)
	{
		GetValues();
	}

	function GetValues()
	{
		var combo = ISGetObject("Regions_WebCombo");
		var values = combo.GetMultipleValues();

		if (values == null || values.length == 0)
		{
			alert("There are no values in Regions_WebCombo!");
		}
		else
		{
			var s = "";
			for (var i = 0; i < values.length; i++)
			{
				var valueItem = values[i];
				s += "Text='" + valueItem.Text + "'; Value='" + valueItem.Value + "'" + " ";
			}
			alert("Values entered in Regions_WebCombo are: " + s);
		}
	}
</script>

I can check them in the DropDown, but why is it not checking them depending on the Values and Text?

See attached graphics.

I tried the WebCombo RefreshValueItems Method Client Side but that did not help.

 

Doug

 

 

 

 

Doug

Hi,

Thanks for the try, I already saw that but your example is for a Standalone WebCombo and does Not work for my example with a WebCombo in each WebGridRow.

How do I make it work for my sample?

Each WebGridRow effectively has different values.

I simplified my sample, but in real life, each of these Values represents a individual record in a Database Table.  When the WebGridRow is updated I will separate these Values from the WebCombo and update Table accordingly using a Stored Procedure.  Likewise when the WebGrid is Loaded, I will take these multiple records Values and concatinate them for the WebGrid Combo.  I have to go this route because there a other relationships on the Table that have to be satisfied, hence the Store Procedure.

Which WebGrid Server Side Event exposes each WebCombo?

Like I referenced in the first post, in the IntializeRow Event I can only get to the WebGridCell and even then it only populates the DropDown display when MultipleSelectionSettings is Not Enabled.  I need MultipleSelectionSettings Enabled.

Or, do I have to do it client side when maybe the DropDown is displayed.

Please try it with my sample.

Thanks,

Doug

All times are GMT -5. The time now is 7:28 PM.
Previous Next