Tuesday, January 6, 2015

Bind the dropdown list & select the required value in dropdownlist in ASP.Net MVC 4 Webgrid

I was struggling to select the value in dropdown. The value comes from database.

I dont think there is a straight way to achieve this unless we do a work around. (please update me if there is!!!)

The work around I did was...

in each collection which we use to bind dropdownlist use "selected=True" for the required value.

i know it sounds crazy, but we dont have any other choice (atleast I dont know any at this time).


It will be a extra step we need to do in controller after we bind the collection to one of the properties of the model.


(I cannot paste my code here...I am sorry)

The steps will be

1. Get the collection of items of the dropdown  [Ex: List<SelectListItem> (City/State)]

2. Iterate through each record of the model  [foreach (Employee emp in Employees)]

3. Assign the collection to the property of the model [Ex: emp.Cities=listCities]

4. Set the Selected property to true to the required value [Ex:- emp.Cities[x].Selected=true]


This is how I found the solution to my requirement. happy coding



Monday, January 5, 2015

Webgrid with Hidden PrimaryKey in ASP.Net MVC 4

It was very weird to know that we cannot have hidden column in webgrid.

Usually we keep Primary Key in hidden field/column in grids.

I successfully overcame this with the following logic.

The logic is :- Use the two fields [one label, one hidden] as HTML contols (one span, one hidden) in "grid.column"


grid.Column("RowNumber", format: item => rowNum = rowNum + 1),

grid.Column(null,header:"RoleName", style: "col4",
                 format:@<p>
                    <span>@item.RoleName</span>
                     <input type="hidden" id="DtoList[@(rowNum - 1)].RoleId" name="DtoList[@(rowNum - 1)].RoleId" value="@item.RoleId" />                    
                 </p>),



I couldn't find a way where we can combine  " RowNumber & Primary Key ".
That may be achievable, but I cannot spend time on that now.

It may help at least one another like me

happy coding..:-)

Thursday, September 4, 2014

an active directory domain controller (ad dc) ....could not be contacted //// the following error occurred attempting to join the domain

I was installing SharePoint 2013 for my development lab. I got these errors while joining my client to domain.

My settings
my domain is domain/netBIOS name is "FA"
my root domain name is "FA.COM"


when I click OK after providing the domain name "FA" in "Computer Name/Domain Changes" window
I am getting "an active directory domain controller (ad dc)........could not be contacted" error.

I provided the DNS details in IPV4 properties.

After that I typed "FA" in the domain name then clicked OK.
It prompted for the domain user name & password to connect to domain. I provided my credentials.
Then I was getting "the following error occurred attempting to join the domain" error.

After sometime I provided IP, DNS settings and tried with "FA.COM" at Domain Name....voilla!!!!!! it worked

if it still doesn't resolve your issue, try to Turn Off windows fire wall on client system.









Internet is not working with static IP (in VMWare)

I was Installing SharePoint 2013 in my development lab. My internet is working fine if I use "Obtain an IP address automatically".
But When I provide my own static IP internet is not working. Yellow symbol (Limited access) is showing in toolbar.

To resolve this error

1. Please remove all your IP settings first. Use "Obtain an IP address automatically"
2. Make sure your internet is working and open Command Prompt type "ipconfig/all"
3. Under "Ethernet Adapter <your adapter name>"  (mine is Ethernet0)
Closely observe these settings

   IPV4 address......
   Subnet Mask.....
   Default Gateway....
   DNS Servers#
               ...........

use these settings to configure your static IP. thats it..:-)

You can change the IP address as you like, do not use 192.168.1.1 & the DNS servers IP

Wednesday, July 31, 2013

Either the 'xxx' user does not have permission to create a new object in 'ServerName', or the object does not exist. (AnalysisServices)

Recently I faced this error while deploying my project to analysis services server in SQL Server 2012.

After some R&D found that, if the user (user xxx in the error message) has Administrator privileges on the  system (where SQL Server is running) then the error is disappeared.


good luck

Saturday, April 20, 2013

sharepoint 2013 the search service is not able to connect to the machine

in SharePoint 2013, I was getting this error while configuring Search Service application.

The error is:- The search service is not able to connect to the machine that hosts the administration component. Verify that the administration component ‘XXXXXXXXXXXX′ in search application ‘Search Service Application 5′ is in a good state and try again.”


The solution for this is :- change the app pool of the search service to "SharePoint Web Services Default". in the properties of the search service.

Steps:-  CA-->Manage Service Applications-->

Select "Search Service Application" (Dont click the link).

in the ribbon control choose "Properties".

then chage the below both services's app pool to  "SharePoint Web Services Default

App Pool For Search Admin Web Service,
Application Pool for Search Query and Site Settings Web Service





Before resolving this issue, I was facing another issue

the error is:

SharePoint 2013 Search not provisioned. "Domain/User" User or Group not found......


The problem is :- in SQL Server Management Studio open Security and then Logins
Here my Service account is registered as "ServerName/Administrtor"
then rename this to "YourDomain/Administrator"

 

 

 

 

Tuesday, August 14, 2012

c# + System.Diagnostics.Process.Star + Access denied

I am getting the "Access denied" error while executing my exe which is internally executing one batch file.

Its working fine in my dev server, but receiving the above error in Prod server.

After searching a while found this atricle @ http://blogsandip.wordpress.com/2011/08/06/resolved-access-denied-error-on-system-diagnostics-process-start/


thanks to author


The trick is 


p.StartInfo.UseShellExecute = false;
p.Start();
p.WaitForExit();