Click here to Skip to main content
14,666,214 members

Comments by Er Daljeet Singh (Top 146 by date)

Er Daljeet Singh 29-Jun-16 8:24am View
Instead of writing "Model.CountryId,null" pass the list<selecteditem> and check whether your model have value of not

var listItems = new List<SelectListItem>()
new SelectListItem {Text = "Male", Value = "M"},
new SelectListItem {Text = "Female", Value = "F"}

@Html.DropDownListFor(m => m.Gender, listItems, string.Empty)
Er Daljeet Singh 29-Jun-16 8:21am View
try the following link
Er Daljeet Singh 27-Jul-15 7:57am View
what do u mean by code behind if your dropdownlist was populated by Jquery.
Er Daljeet Singh 27-Jul-15 7:52am View
Instead of writing this.form1.Controls.Add(lnk);
if (e.Row.Cells[1].Text == "dontselect")
lnk.Visible = true;

hope this work
Er Daljeet Singh 27-Jul-15 7:39am View
Instead of using " IEnumerable<t> agg = source;"use List<t> agg=source,ToList();
Hope this will work
Er Daljeet Singh 27-Jul-15 7:35am View
Well dataGridView normally bind with Datatable.So its better to create Datatable and store value in datatalbe from textboxes and then click of submit/save button bind the Datagridview
Er Daljeet Singh 20-Jul-15 10:16am View
why don't you do that with the help of jQuery.
When a click submit call a jquery function whether lastname is "TBD" or not if it is "TBD" display the popup. and dropdown will be filled with help of Ajax call.
Er Daljeet Singh 20-Jul-15 10:05am View
I agree with "Sergey Alexandrovich Kryukov" If you want to manipulate data then do that on code file but still if u want to do achieve this then try this...

ListView2.Items.ToList().ForEach(m => { ListView3.Items.Add(m); });
ListView1.Items.ToList().ForEach(m => { ListView3.Items.Add(m); });

hope this help
Er Daljeet Singh 15-Jul-15 3:53am View
if u want to fetch Single Record then Write
var Data= (from c in db.Profilewhere select;
this will return you the object of Type Profile
Er Daljeet Singh 15-Jul-15 3:18am View
As Lakhan Anjana told if you want to Fecth the ID then Simply Write
var Data= from c in db.tablename where select;
Or u can write

List<int> list=db.Profile.Select(m=>m.ID).ToList();
It Will return u the list of Id from the Profile table.
Er Daljeet Singh 15-Jul-15 3:14am View
What do you mean by calling Gridview in link button?
Please elaborate what you want to do.
Er Daljeet Singh 4-Jun-14 8:54am View
What's your exact problem you are saying "Page Not found" its another issue if have problem with entity framework then let us know.
Er Daljeet Singh 28-Apr-14 6:55am View
Post the code what u had done.
Er Daljeet Singh 28-Apr-14 6:49am View
Comment your If condition and check whether your application is creating linkbutton or not if not then debug your code again.
Er Daljeet Singh 25-Apr-14 2:06am View
Check the name of the table in database your database there is spelling mistake in it.
Er Daljeet Singh 25-Apr-14 1:49am View
"show a function" means the function that are visible to user via OperationContext.
Can u post some code for how to implement two interfaces in a service.
Er Daljeet Singh 23-Apr-14 7:17am View
What's the probelm with that.
post the code of your view page
Er Daljeet Singh 23-Apr-14 7:14am View
no we don't need globalization.
ToString is inbuild function in C#
just call it as it is.
Er Daljeet Singh 23-Apr-14 7:03am View
its simple call .ToString() function
int a=0;
Er Daljeet Singh 23-Apr-14 7:02am View
Its not clear to us tell us what u exactly want to do..
Er Daljeet Singh 23-Apr-14 6:49am View
for this to implementation jquery is best suited.
Er Daljeet Singh 23-Apr-14 6:47am View
you need to use sql join for that
Er Daljeet Singh 23-Apr-14 6:43am View
try to maintain the value of DataItemIndex in a variable and use that variable outside the PageIndexChangedEvent
Er Daljeet Singh 23-Apr-14 6:34am View
Check the value for "gvrow.DataItemIndex"
Er Daljeet Singh 23-Apr-14 6:24am View
check your database column and the entities you had created.
there name should be same otherwise go to Model Browser window and check the mapping there.
Er Daljeet Singh 23-Apr-14 6:21am View
Just use debugger and check whether "GridViewRow gvrow = UssdGridView.SelectedRow;" this line having value of not.
Er Daljeet Singh 21-Apr-14 7:41am View
check the value of "filename" variable it is having some illegal character
Er Daljeet Singh 21-Apr-14 6:54am View
You can use jquery for this.
else try ModelState.AddError() functiin in your Action
Er Daljeet Singh 10-Jan-14 1:14am View
post the code what you have done..
Er Daljeet Singh 31-Dec-13 0:13am View
Read your string character by character and check whether the particular character is Digit or not ,if it is then append it to another string that's sit
Er Daljeet Singh 6-Dec-13 7:15am View
Dear everything working fine and there is no need to put the dropdownlist inside the update panel i jusat want to display the progressTemplate..
Er Daljeet Singh 29-Nov-13 4:30am View
post you code with some database values
Er Daljeet Singh 29-Nov-13 4:14am View
post the code where you are getting this error
Er Daljeet Singh 29-Nov-13 2:17am View
check this link
Er Daljeet Singh 29-Nov-13 1:51am View
put your code where you stuck..
Er Daljeet Singh 29-Nov-13 1:03am View
what you have done so far put here?
Er Daljeet Singh 28-Nov-13 1:11am View
post your code where you want to implement this.
Er Daljeet Singh 26-Nov-13 5:35am View
if you want o display records horizontally then use datalist instead of gridview.
Er Daljeet Singh 26-Nov-13 4:35am View
Instead of using 4 update panel use a single update panel and take a multiview control inside that panel.with the help of multiple view you can achieve what you want to do.
Er Daljeet Singh 26-Nov-13 4:31am View
What have you tried and where is the problem?
Er Daljeet Singh 26-Nov-13 0:29am View
dear you are getting skills somewhere from the web page right then why don't you check wheter user added skill or not.
second option is when you bind your datagrid then at that time you also check whether the source is having the value or not.

i dont think you if dont set the controltovalidate property the custom validator work.
Er Daljeet Singh 26-Nov-13 0:00am View
<asp:CustomValidator ErrorMessage="At least one skill is required" ClientValidationFunction="ValidateSkills" ValidationGroup="formVal" runat="server" CssClass="errorClass" Display="Dynamic" />

here you forgot the ControlToValidate property .
write ControlToValidate="nameofcontrol" attribute then try again..
Er Daljeet Singh 25-Nov-13 23:46pm View
check whether your alert is displaying or not.
Er Daljeet Singh 25-Nov-13 23:45pm View
which class you had added/createed on the dbcontext.
Er Daljeet Singh 25-Nov-13 6:43am View
could you post the code for custom validator as well as the javascript function
Er Daljeet Singh 25-Nov-13 4:44am View
put the code of the button_click function inside a condition
//code here

i think your validation are working from server code and check whether validater are working or not.
Er Daljeet Singh 25-Nov-13 4:24am View
post your code what you have implemented
Er Daljeet Singh 25-Nov-13 1:49am View
it simple when you select a row from gridview then fetch the ID -Column from the row and and read the record from the data base having same id and bind that record to the repeater.
Er Daljeet Singh 25-Nov-13 1:27am View
try to check when you bind your datalist to some source at that time check whether the source is having record greater than 2 or not.if greater then write
DataList1.RepeatColumns = 2;
DataList1.RepeatColumns = 1;
Er Daljeet Singh 22-Nov-13 5:47am View
could you provide the code where you are passing the value of listbox into dataaccesslayer
Er Daljeet Singh 22-Nov-13 4:55am View
but the code you have posted work fine if you set EnableClientScript=true.
this property simple check whether you want to check the validation at server of client side.
if this property is true then its means we want to check the validation at client side.
Er Daljeet Singh 22-Nov-13 4:32am View
for a good answer post your question carefully..
Er Daljeet Singh 22-Nov-13 4:20am View
post the code where you stuck.
Er Daljeet Singh 22-Nov-13 4:19am View
post the code where you stuck.
Er Daljeet Singh 22-Nov-13 4:19am View
post the whole code here.
so we can find where is the problem.
Er Daljeet Singh 22-Nov-13 1:11am View
string runActual = (getRunTimeActual[0].ToString());
it will work only in case when your query will return atleast single record.
Er Daljeet Singh 22-Nov-13 1:00am View
i made some changes in query now execute and test it.
quite similar to previous one but working fine...
Er Daljeet Singh 21-Nov-13 7:00am View
its simple if you want to replace .JPG with .jpg
1)use string.Replace(".JPG",".jpg")
2)use string.ToLower();
Er Daljeet Singh 21-Nov-13 6:56am View
Provide the data that you have in file.
you said that every line has three float values i just want to how the values a represented in the string.
Er Daljeet Singh 21-Nov-13 4:50am View
in the previous question you had already created a parametrized constructor so why you are asking this.
Er Daljeet Singh 21-Nov-13 4:48am View
just do one thing in Singleton class where you have created a parameterised constructor before calling it call the base class construstor means you have to implement constructor chaining here is the syntax

Singleton(String connectionString):base(connectionString)
// whatever
Er Daljeet Singh 21-Nov-13 4:28am View
the use of USING keyword is that it will automatically remove the object or release the memory created by the instance of Entites when the scope of Entities instance in going out.
Er Daljeet Singh 21-Nov-13 4:22am View
try to put content of you doc file here in codeproject
Er Daljeet Singh 21-Nov-13 4:16am View
try this code

class PrintDoc : PrintDocument
public Font font;
string text;
protected override void OnPrintPage(PrintPageEventArgs e)
if (text == null) text = File.ReadAllText(this.DocumentName);
int chars, lines;
SizeF textSize = e.Graphics.MeasureString(text, font, e.MarginBounds.Size, StringFormat.GenericTypographic, out chars, out lines);
string textDrawn = text.Substring(0, chars);
e.Graphics.DrawString(textDrawn, font, Brushes.Black, e.MarginBounds.Location);
if (chars < text.Length)
text = text.Substring(chars);
e.HasMorePages = true;

on button click

PrintDoc doc = new PrintDoc();
doc.DocumentName = @"C:\Users\daljeet\Desktop\Modified_Files_Name.txt";
doc.font = new Font("Consolas", 9);
Er Daljeet Singh 21-Nov-13 2:52am View
when you add the reference of the service in you project a folder with name "ServiceaReference" is created in this folder your CustomerService.SVC simply right click on ServiceReference folder and select "Update service reference" it will update your service.
Er Daljeet Singh 21-Nov-13 2:47am View
what you want to do exactly.
you want to get the sum of all the element in array using threading or you have some different scenario.
Er Daljeet Singh 21-Nov-13 2:41am View
you are getting this because when you try to delete file at that time it is open or in processing.if you are using then web application then why don't you use fileupload control for saving images.
Er Daljeet Singh 21-Nov-13 2:36am View
first thing in if you try to find the id of linkbutton through btn_Click() you will get same Id.
second the in datalist you have not mentioned the onitemcommand="DataList1_ItemCommand" in you HTML page thats why it is not working.
Er Daljeet Singh 21-Nov-13 2:30am View
once you update you service then you need to update the the service reference also where you are calling your service.update the service reference in the project where you had user service.
Er Daljeet Singh 21-Nov-13 2:26am View
try to give the relative path not the absolute path
use Server.Mappath() for giving the path to the printdoc function
Er Daljeet Singh 20-Nov-13 6:22am View
can you tell me what is this "stored procedure in json"
both store procedure and json are two different thing.
so tell us exactly what you want to do...
Er Daljeet Singh 20-Nov-13 5:19am View
try to replcae '#' with '?' then fetch query string
Er Daljeet Singh 20-Nov-13 5:08am View
i had post a solution just go through it.
Er Daljeet Singh 20-Nov-13 4:41am View
means you have a image control in datalist.
Er Daljeet Singh 20-Nov-13 4:13am View
post the code of getEmp() function.
or run your code put a breakpoint and check whether tm.GetEmp(); returning value or not.
Er Daljeet Singh 20-Nov-13 3:05am View
here is some modification in your code
<script type="text/javascript">
function updateValue() {
var one = document.getElementById('one');
var two = document.getElementById('two');
var three = document.getElementById('three');
var four = document.getElementById('four');
var five = document.getElementById('five');
two.value = parseInt(one.value) - 100;
three.value = parseInt(two.value) - 50;
four.value = parseInt(three.value) - 50;
five.value = parseInt(one.value) - (parseInt(two.value) + parseInt(three.value) + parseInt(four.value));
function numeralsOnly(evt) {
evt = (evt) ? evt : event;
var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
if (charCode > 47 && charCode < 58) {
else {
if (charCode == 8) {
return true;
else {
return false;

<p align="center">
Enter the amount to be paid<input id="one" type="text" onchange="updateValue()" önkeypress="return numeralsOnly(event)" />
Book fees<input id="two" type="text" name="txt" />
uniform fees<input id="three" type="text" />
Bus fees<input id="four" type="text" />
balance fees<input id="five" type="text" />
Er Daljeet Singh 20-Nov-13 3:04am View
again we are not getting anything.
yes we understand you want to deduct 100,50,50 but from which which text box you want do deduct it.
you said if user enter 300
1st textbox=300
2nd textbox= minus 100
3rd textbox= minus 50
4th textbox= minus 50
5th textbox=100

but from which value we want to deduct.
suppose if i minus 100 from 300 then 200 balance now for the third texbox from which value if want to deduct whether from 300 ,200 or the balance.

Clearly ask what logic you want to implement.
Er Daljeet Singh 20-Nov-13 1:58am View
provide the structure of your table.
means on behalf of which table you want to update the record.
Er Daljeet Singh 20-Nov-13 1:53am View
Try to search it on google before asking a question.
Er Daljeet Singh 20-Nov-13 1:48am View
post the GetEmp() method, i want to see what it is returning.
Er Daljeet Singh 20-Nov-13 1:39am View
What you want to do exactly we are not getting anything from your question..
Er Daljeet Singh 20-Nov-13 1:17am View
Its not clear what you want to elaborate your question
Er Daljeet Singh 20-Nov-13 0:31am View
Post your code first then we will to able to know what you want to achieve.
Er Daljeet Singh 19-Nov-13 5:18am View
read user question what you are trying to ask from our side..
Er Daljeet Singh 19-Nov-13 5:14am View
create a class which is having properties same as that columns you have in datatable.
then create a generic list of MyClass type.
then iterate the datatable.rows property which will return you row one by one ,fetch the value from row and add it to the property of myclass
then add add that object to the list.
Er Daljeet Singh 19-Nov-13 4:30am View
Post your code where you are binding textbox or label with datatable.
Er Daljeet Singh 19-Nov-13 4:24am View
not a problem we can also find the ajax control also.

AjaxControlToolkit.Rating id = (AjaxControlToolkit.Rating)FormView1.FindControl("ajaxRating1");
Er Daljeet Singh 19-Nov-13 2:21am View
first check whether you datatable in having value or not by putting breakpoint.
if yes then what error you are getting..
Er Daljeet Singh 19-Nov-13 2:15am View
if your are creating dropdown from code behind then you wiil not able to find that.beacuse on every postback you have to create the dropdown list.
Er Daljeet Singh 19-Nov-13 2:05am View
we are not getting anything.
tell us briefly what you want to do...
with proper description.
Er Daljeet Singh 19-Nov-13 2:04am View
post your code where you are getting error.
Er Daljeet Singh 19-Nov-13 2:02am View
tell me one thing you are creating dropdownlist through code mean from code behind.
Er Daljeet Singh 19-Nov-13 1:56am View
for achieving this first try to read the column from the excel sheet.
then create a datatable with same number of column you are having in excel sheet.
after that alter your table in datable through code with schema as that of datatable .then with the sqlbulkcopy class insert data from datatable to database.
Er Daljeet Singh 19-Nov-13 1:53am View
i think here "templatesetset .count() has 14 records." is returning you the number of columns in you table.
Er Daljeet Singh 19-Nov-13 1:50am View
can you share the column of your table.
Er Daljeet Singh 19-Nov-13 1:47am View
We are here on the codeproject for sharing our knowledge and finding solution to our porblem.SO thanks you to also for sharing your knowledge..
Er Daljeet Singh 19-Nov-13 1:44am View
try by changing the name of the dropdown list..

DropDownList div2 = (DropDownList)Master.FindControl("ctl00_ContentPlaceHolder1_perage['"+pcnt+"']");

i think this will work fine..
Er Daljeet Singh 19-Nov-13 1:40am View
i think you should try your code by selecting two record from the datalist.
try to add 2item in your cart and see what happen,
Er Daljeet Singh 19-Nov-13 1:34am View
Tell us exactly what you want to do...
Er Daljeet Singh 19-Nov-13 1:29am View
the code you had posted is correct but you need two modification.
first check whether the record you are having the table are distinct of not in your case i think you have multiple TemplateEntityList in the table.
second you should modify your foreach loop

Template obj = new Template();
obj.TemplateID = templatesetset[0].TemplateID;
obj.TemplateName = templatesetset[0].TemplateName;

here in this code you had put zero so it will always read first record only.
Er Daljeet Singh 19-Nov-13 1:19am View
you need add the reference of the Microsoft.Office.Interop.Excel.DLL reside inside the COM tab
Er Daljeet Singh 19-Nov-13 1:00am View
in you for loop.
Er Daljeet Singh 19-Nov-13 1:00am View
try to use this code ....
if (str != emp)
rowz[i] = sheet.Table.Rows.Add();
rowz[i].Cells.Add(s + str );//This will be displayed in excel,how to make it Bold???
using xl = Microsoft.Office.Interop.Excel;
xl.Range rng = (xl.Range)rowz[i];
rng.Font.Bold = true;
row[i] = sheet.Table.Rows.Add();
Er Daljeet Singh 19-Nov-13 0:51am View
Use fileupload control to upload your image onto the server and then assign the path of the image to the image control.
Er Daljeet Singh 19-Nov-13 0:26am View
what you are using means you are using window application or a web application..
Er Daljeet Singh 18-Nov-13 0:57am View
you can simply find a control by using find control function.

Label id = (Label)FormView1.FindControl("Label1");

here i am finding a label from formview with the help of find control function.
you can directly find the control from forview because it display one record at a time..
Er Daljeet Singh 18-Nov-13 0:48am View
i think the code you had posted will work fine.but tell us what problem you are facing,..
Er Daljeet Singh 18-Nov-13 0:45am View
Dude what is it?
we are not getting any thing?
what want exactly from our side.try to elaborate you question..
Er Daljeet Singh 18-Nov-13 0:43am View
Refer these links ..
Er Daljeet Singh 18-Nov-13 0:40am View
I don't think you will get Average() function with f.Rating beacuse it a returning a single value and you will not get average function there.
Er Daljeet Singh 18-Nov-13 0:22am View
What error you are getting.
Er Daljeet Singh 15-Nov-13 7:12am View
if you to use asp button then do on thing
Go to source file and in the page directive add a attribute "MaintainScroolBackPosition=true"
this property will maintain the position of scrollback on postback.
Er Daljeet Singh 15-Nov-13 7:08am View
let me clear one thing..
you are having a master page on which you have dropdownlist now you to fire the dropdownlist_SelectedIndexChanged from content page.
just do one thing.
dont fire any event of dropdown from master page and then write the code i posted in the content page.
Er Daljeet Singh 14-Nov-13 7:27am View
try to use javascript event named "onblur" for achieving this.
Er Daljeet Singh 14-Nov-13 7:24am View
Go through this link
Er Daljeet Singh 14-Nov-13 7:22am View
your code in little bit confusing.You are inheriting you view from Sw_workdescription class but there is now property named WorkDescriptionther is no link between Sw_worddescription class and your WorkModel class that is confusing.Try to put your whole code i.e. your view and model files
Er Daljeet Singh 14-Nov-13 7:11am View
have you changed the name of dropdownlist in the code or not.
or try to do one thing run your code check the name of the dropdownlist in browser and copy that name into you code.Something if you place some control in master page and find that controls on content page then name of the control will be changed.

Er Daljeet Singh 14-Nov-13 5:41am View
yes it is possible with the help of Event and Delegates...
Er Daljeet Singh 14-Nov-13 5:39am View
Put this code on Page_Load Event
Er Daljeet Singh 14-Nov-13 5:31am View
can you please explain the hierarchy of the classes.
please name all the classes you have created or created by .EDMX file.
one more tell from which class you are inheriting your view.
Er Daljeet Singh 14-Nov-13 1:28am View
Are you sure that hidden field in displaying in the gridview when you run your page.
Er Daljeet Singh 14-Nov-13 1:26am View
Dear first of all add some value in the listbox ,
second check wether the session is having or not.
third i session is having value then that value should be present in the listbox
Er Daljeet Singh 8-Oct-13 2:49am View
There is problem in you javascript so please modified it.I am also posting soultion.
Er Daljeet Singh 8-Oct-13 1:47am View
This is because you sqldatasource execute's the store procedure only once if if you want to change the gridview then reconfigrue your sqldatasource at runtime
Er Daljeet Singh 8-Oct-13 1:35am View
Srishti you cannot call class function or server side function directly from javascript.For doing so you need to register your function to the DOM with the help of Ajax.I am posting sample code for this scenario.
Er Daljeet Singh 30-Sep-13 8:31am View
I am going to post the code which in working fine in web application.
Er Daljeet Singh 30-Sep-13 8:05am View
No we don't need to convert a bit array or byte array for web application.IF your bit array stored in db is correct then you just need to create a image fro that bit array that's sit.nothing else.
Er Daljeet Singh 30-Sep-13 5:46am View
Dear you should whether your "context.SaveChanges();" is called on not.
Er Daljeet Singh 30-Sep-13 5:20am View
Its a pleasure dear for me to help someone.
Er Daljeet Singh 30-Sep-13 5:18am View
Yes i know its a web application.
May be you are getting this error because of your Byte Array.Check the image you are storing in you database is correct or not.Actually i don't have image in database that's why i used window app to easily convert it into byte array.Just check you byte array run the code again,That code is working fine scenario.
You can check in this link where i have created a captcha,
Er Daljeet Singh 26-Sep-13 7:06am View
ok i got your question you want to create observer mean if the value from parent class changes it will reflect child class also. i am right
Er Daljeet Singh 26-Sep-13 6:57am View
Just do 1 thing remove the register directive from you page after that go to the design view and and drag the usercontrol again.
Er Daljeet Singh 26-Sep-13 6:53am View
Dude Check whether you gridview i giving you the url of the image or not.
if it is giving url then check wheter image exist in your application folder or not.
Er Daljeet Singh 26-Sep-13 6:32am View
Will you please provide the code you have wrote into your form.
and Post the storeP also.
Er Daljeet Singh 26-Sep-13 6:25am View
Will you please post the code where you are getting error.
Er Daljeet Singh 26-Sep-13 6:04am View
I am going to post code again
Er Daljeet Singh 26-Sep-13 4:22am View
Provide the whole code file where you are getting error both file Code/Design.Other wise just restart your Visual Studio and try again.
Er Daljeet Singh 26-Sep-13 3:53am View
I have modified the code.Please check it again and tell us whether it is working or not
Er Daljeet Singh 25-Sep-13 7:41am View
Dear you question is not cleared please elaborate it clearly.
Er Daljeet Singh 25-Sep-13 7:37am View
i dont think int / bigint is an issue.
because same case is working fine in my case.
Er Daljeet Singh 25-Sep-13 6:11am View
OK i will post a sample for you.
Er Daljeet Singh 25-Sep-13 6:05am View
Thanks Thomas....
Er Daljeet Singh 25-Sep-13 5:23am View
NO i don't think it works because <tr> in inside the loop or secondly the model should have records in format the user want to display.
Er Daljeet Singh 25-Sep-13 4:02am View
You need to write jquery/javascript code to fire the event from server side.
Er Daljeet Singh 25-Sep-13 3:58am View
How you are binding the data with gridview.You are binding the data manually or using the SqlDataSourceControl
Er Daljeet Singh 25-Sep-13 3:54am View
This solution is really good.But on which event i should write this code whether i should write in it TextChanged event or any other event.