Friday, August 28, 2009

ASP Net - DateTime conversion

ASP Net - DateTime conversion

Hi,

I am tryoing to convert the following string to a
date. Unfortuanly I get the error: "String was not
recognized as a valid DateTime."

This is my code:

CheckDate("2004-11-01T21:18Z")

private function CheckDate(ByVal strPostDate as string)

Dim dtDate As DateTime = Convert.ToDateTime
(strPostDate)
end function

Can somebody help me?


Vishal


View Full Details...............................

Convert string to DateTime

Convert string to DateTime

This code snippet shows how to convert a string to a DateTime object. This method returns false if the string cannot be converted to a valid date in the specific format.

You can specify more formats in the variable "supportedFormats".

Eg:
dim myDate as DateTime = DateTime.Now
if ( ConvertToDate("12/10/2007", myDate ) then
' The date is valid. The variable myDate has the converted date.
end if



View Full Details...............................

ASP.Net Convert String to DateTime Using VB

ASP.Net Convert String to DateTime Using VB

In ASP.Net to convert string into DateTime you can use Convert.ToDateTime function in VB. Further you can also format the output of Date or Time according to your requirement, using different VB Format Date patterns such as MM/dd/yyyy, dd-mm-yyyy etc.

First of all create a string variable to store the string type DateTime.

Dim myDateTimeString As String

Then create a new variable of type DateTime and pass the string to DateTime variable using Convert.ToDateTime function.





View Full Details...............................

ASP - Convert String to Date

ASP - Convert String to Date

ASP makes converting string to date very easy. We’re going to use the CDate ASP/VBScript function in our ASP code to convert a string to a date value.

ASP CDate function has the following syntax:

CDate (Date)

ASP CDate function has 1 string argument, which is the string to be converted to date.
The CDate function converts any valid date/time string expression to Date variant subtype.

Consider the following use of ASP CDate function, to convert sDate string to date:

<%
sDate = "January 13, 1970"
Response.Write CDate(sDate)
%>

The result displayed in your browser will be:

1/13/70

date conversion

date conversion

How do I convert 2/1/2006 to February 1, 2006?

Thanks.


View Full Details...............................

How to convert a string to a date

How to convert a string to a date

Finding out how to convert one type to another in .NET is tricky. Here is the answer to converting a string to a DateTime type. Notice that any of the string formats work -- how nice!

//string strDate="2002-10-03";
//string strDate="10/04/2002";
string strDate="10/05";
DateTime dt = (DateTime)(TypeDescriptor.GetConverter(new DateTime(1990,5,6)).ConvertFrom(strDate));
Response.Write("

" + dt.DayOfWeek);




View Full Details...............................

Convert Pdf to Word and Word to Pdf

Convert Pdf to Word and Word to Pdf
hi,
Using c# I want too convert a pdf document to word and also word document to pdf .


Thanks in Advance,
A.Durga Prasad

Open Source PDF Libraries in C#

Open Source PDF Libraries in C#

Report.NET is a powerful library that will help you to generate PDF documents in a simple and flexible manner. The document can be created with data that have been retrieved from any ADO.NET data set.a

Component to Convert PDF to Word, using .net 2.0

Component to Convert PDF to Word, using .net 2.0


Hello,

I need help in finding which is a best component that doesn't require lots of coding to convert a word document to pdf using C#, asp.net 2.0.

I found we can write to pdf using iTextSharp, but I didn't see a way it can directly convert word to pdf.

Appreciate your feedback as soon as possible.







View Full Details...............................

convert word doc into PDF using c# code.

convert word doc into PDF using c# code.


hi guys,
i'm having very terrible problem. I need to print a word doc into pdf.
for this i'm using gostscript to create a virtual printer (http://
www.stat.tamu.edu/~henrik/GSWriter/GSWriter.html). and using microsoft
c# code to call this printer and print the document into pdf (http://
support.microsoft.com/kb/322091).

i'm not able to make this C# code work. whenever i'm posting a
document to the printer, it is getting deleted from the print queue
(win32 exception code: 63).
i tried various options on ghostscript virtual printer and also tried
to modify the c# code but not able to do anything around.

if some one had done something like this before, i would appreciate if
you will share your experience. or someone has some better ideas to do
it other way, i would also welcome that as well.

plz guys do post your comments.

Lucky



View Full Details...............................

ASP.NET convert DOC to PDF programmatically

ASP.NET convert DOC to PDF programmatically

We have an ASP.NET app on a shared web hosting account (so no root access) and need to convert word .doc files to pdf. We already have a component to convert html to pdf so we could also use something to just create .doc to .html. It seems like most of the commercial components either a) need root access, or b) need Office (or OpenOffice) installed, and neither of these are an option. Hopefully someone can help?!




View Full Details...............................

Convert Word-Documents to PDF on an ASP.NET Server

Convert Word-Documents to PDF on an ASP.NET Server

Introduction

This PDFConverter converts Microsoft Word documents (*.doc) into PDF-files on a Webserver. There is a simple Webform, where you can upload your Word-Document, which will be converted and sent back as a PDF-File.

Prerequisites

  • Microsoft Word 2007
  • 2007 Microsoft Office Add-in: Microsoft Save as PDF or XPS
  • A User, who has the rights to execute Word, must be logged in on the Server
  • The PDFconverter.exe must be running (part of this project)

Serverside PDFConverter.exe (app.config):

<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown objecturi="RemoteConverter"
type="PDFConverter.RemoteConverter, RemoteConverter" mode="Singleton">
</wellknown>
<channels>
<channel port="8989" ref="http">
</channel>
</channels>
</service>
</application>
</system.runtime.remoting></configuration>



View Full Details...............................

Convert PDF to Word

Convert PDF to Word

* Language: ASP.NET
* Download: complete source code (zip)
* Requirements: None



View Full Details...............................

Convert word doc to pdf

Convert word doc to pdf

How can I convert a word doc uploaded by the user to a pdf?
How can I store the converted pdf in the database?

am using asp.net 1.1 and vb.net

Nina


View Full Details...............................

Wednesday, August 19, 2009

Global Variable in ASP.NET

Global Variable in ASP.NET

Hi,

I have 2 dropdownboxes.

Whenm the user selects from the dropdownboxes the selectedvalues are assigned to 2 variables (declared as public in c# file)

How do I use these variables in sql server queries?

Thanks.


View Full Details...............................

What is Remote HTTP Post using CSharp

What is Remote HTTP Post using CSharp

What is Remote HTTP Post using CSharp?
What is the use of it?
Can any one guide me to do this step by step so that i can understand it.
Is there anyone who can guide us?

I have google it http://stackoverflow.com/questions/5...st-with-csharp but it is not so answered my above question.

Thanks,
Ujjwal Das


View Full Details...............................

Difference between .Net3.5 and .Net2.0

Difference between .Net3.5 and .Net2.0

Hi

I want to know about the difference between .Net3.5 and .Net2.0 ?

Thanks



View Full Details...............................

Random Query Param For Multiple Windows

Random Query Param For Multiple Windows

I am trying to create a query string that opens a web with a page redirect and appends a generated random number as follows:

Dim myRandom AsNewSingle
myRandom = Rnd(5)
Response.Redirect(
"http://MyLocalMachineName/MyWebApp/Default.aspx?sender=" & myRandom, True)

However, if this has been run once and the default page is open, I am unable to run this code again until I close the default page. Any ideas why that is?

Thanks again.

Chris


View Full Details...............................

page reload problem

page reload problem

hi guys,
in asp.net page i have designed a registration page few textbox are in that page i have set field validators on them but problem is that there are two buttons one is for register and the other is to go back to main page when i am clicking submit button with value then validators are stoping page to reload thats ok but if without register any thing when i am clicking back button validators even highlights those fields to fill and cant go back to main page what i do for this??? and i am doing this in asp.net with vb.net


View Full Details...............................

How do I convert an HTML Page exactly as it is into aspx page

How do I convert an HTML Page exactly as it is into aspx page

http://www.time.com/time/business/ar...,00.html#drawn


this is one of the good website i searched through google..

If i want to convert a similar website to aspx page how do i do that.

This is urgent requirement .

It should be 100 percent conversion . I tried renaming the html extension as aspx it doesnt work and even copying the source contents of the html page and pasting it in aspx page also doesnt work

If you solve this i will be very grateful. Thank u .......

View Full Details...............................

Call to WCF timeout on the second call

Call to WCF timeout on the second call
Hi,

I a real newbie on WCF, and I want to implement a service that reads from a DB some data and returns generic lists of custom objects to the client.

So I implement the service like this:
Interface:


vb Syntax (Toggle Plain Text)
  1. ()> _
  2. Public Interface IRepositorio
  3. (Name:="ListarAlmacen")> _
  4. Function ListarAlmacen() As List(Of BE.Almacen)
  5. End Interface

Implementation:


View Full Details...............................

Populate textfields from a dropdown list box using datasource

Populate textfields from a dropdown list box using datasource

Hi, I have been pulling my hair out for the last few hours trying to solve this. I have found that you can get a value for DropDownListSelectValue.changed however i need multiple values.

I have configured my dropdown list to Select Name From Resources, however on the query i have selected everything.
Now when I used the selectedindexchanged I am able to extract the Resource Id and fill a textbox with it.
I need to do the same for another 5 or 6 fields and am not use how i go about this.
If anyone could post a C# guide/code It would be very much appreciated.


View Full Details...............................

Custom TreeView wont fire SelectedNodeChanged event.

Custom TreeView wont fire SelectedNodeChanged event.

Hi Folks,

I hope someone can help me with a problem i'm having with the TreeView-control.

I'm using a custom TreeView (derived) that gives a postback when the user checks a checkbox, see code below. This works fine though, but now the TreeView isn't firing the SelectedNodeChanged event when clicking a node. It does postback though.

Am I missing something with the PostBackReference or something? I'm quite new in this, so bear with me :)

Here's the code for the custom TreeView:


public class TreeViewCheckbox : ASP.TreeView, IPostBackEventHandler
{
public event EventHandler CheckClick;

protected override void Render(HtmlTextWriter writer)
{
StringBuilder builder = new StringBuilder();

using (StringWriter stringWriter = new StringWriter(builder))
{
HtmlTextWriter tempWriter = new HtmlTextWriter(stringWriter);
base.Render(tempWriter);
}

string find = " string replace = "
writer.Write(builder.ToString().Replace(find, replace));
}

protected string getPostBack()
{
return this.Page.GetPostBackEventReference(this, "@CheckPostBack");
}

protected virtual void OnCheckClick(EventArgs e)
{
if (CheckClick != null) CheckClick(this, e);
}

void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)
{
OnCheckClick(new EventArgs());
}

}



Thanks!
View Full Details...............................

Event not firing on multiple master pages

Event not firing on multiple master pages

I have a page inherited from multiple master pages. This is what I have

Main Master --> Second master --> Applicant Page

I can see the page load firing from the Main Master and Applicant Page but not from the Second master

Can some please let me know what can be the problem here?

Thanks



View Full Details...............................

Is it possible to add CCS to Master Page (ASP.NET in Visual Studio 2008)

Is it possible to add CCS to Master Page (ASP.NET in Visual Studio 2008)

Is it possible to add CSS to a Master Page? I need to ad a nav menu on the left side of the Master Page so that this menu appears on all the pages. When I attempt to add the StyleSheettheme attribute to the master page I get an error message saying this is not possible. The error message also states that it may be possible to add style sheets but this has to be done in the visual designer. I am uncertain of how to accomplish this. If anyone knows how to add CSS to a master page via the page directive or in the visual designer please let me know. If you know of a different method such as using Silverlight or AJax and can direct me to a link I would appreciate that.

Again, the main objective is being able to have a left side vertical navigational menu on the master page. If your sample code includes both left-hand vertical menu and top-of-page horizontal menu that would be ideal.

Tools: In additional to VS2008, I also have Expression Studio 3. I am more comfortable with VS (only a few days experience with Expression) but I am willing to give Expression a try if solution requires this.





View Full Details...............................

Expand a child node in a treeview that is in a master page from a content page

Expand a child node in a treeview that is in a master page from a content page

need to expand one of the nodes in my treeview from a content page.
Everything I have tried has not worked. The Treeview is located in a
Master Page and built from a web.sitemap. I have a content page that
is not listed in the sitemap, but I still need to expand the node.
Please provide the solution in VB.

I have been able to expand by depth by using the following.

Dim MasterTree As TreeView
MasterTree = DirectCast(Master.FindControl("TreeView1"), TreeView)
MasterTree.ExpandDepth = 0
What I need to do is to pick a child node and expand it from the
content page. (the administration node)

Thank you in advance for your assistance. Below is my Sitemap


http://schemas.microsoft.com/AspNet/SiteMap-File-1.0"

url="Default.aspx">

url="ItemsForBid.aspx" securityLevel="">

securityLevel="200">

securityLevel="500">


description="Administration" url="" securityLevel="900">
url="Admin/SecuritySearchNew.aspx" />
url="Admin/SecuritySearchExist.aspx" />


url="Admin/UpdateItems.aspx" />

url="ContactUs.aspx" securityLevel="">


need to expand one of the nodes in my treeview from a content page.
Everything I have tried has not worked. The Treeview is located in a
Master Page and built from a web.sitemap. I have a content page that
is not listed in the sitemap, but I still need to expand the node.
Please provide the solution in VB.

I have been able to expand by depth by using the following.

Dim MasterTree As TreeView
MasterTree = DirectCast(Master.FindControl("TreeView1"), TreeView)
MasterTree.ExpandDepth = 0
What I need to do is to pick a child node and expand it from the
content page. (the administration node)

Thank you in advance for your assistance. Below is my Sitemap


http://schemas.microsoft.com/AspNet/SiteMap-File-1.0"


url="Default.aspx">

url="ItemsForBid.aspx" securityLevel="">

securityLevel="200">


securityLevel="500">



description="Administration" url="" securityLevel="900">
url="Admin/SecuritySearchNew.aspx" />
url="Admin/SecuritySearchExist.aspx" />


url="Admin/UpdateItems.aspx" />

url="ContactUs.aspx" securityLevel="">




View Full Details...............................

Tuesday, August 18, 2009

Selecting from DropdownList Reloads Page

Selecting from DropdownList Reloads Page

Hi,
I have 2 dropdownlist controls.
I bind the controls when the page loads.

However, when I select from the dropdownlist the page reloads and the bindings are reset. Meaning that the default value is always selected.

How do I fix this? Below is my code. Thanks.


if (!IsPostBack)
{
NameList.DataSource = NameDataSet;
NameList.DataTextField = "Name";
NameList.DataValueField = "Name";
NameList.DataBind();

DateDropDownList.DataSource = DateDataSet;
DateDropDownList.DataTextField = "Date";
DateDropDownList.DataValueField = "Date";
DateDropDownList.DataBind();

name = NameList.Text;
date = DateTime.Parse(DateDropDownList.Text);
loadData();

}
else {

}



View Full Details...............................

How can I merge the headertext of a gridview

How can I merge the headertext of a gridview

I have got 5 columns
Column A - Name
Column B - Age
Column C - Choice 1
Column D - Choice 2
Column E - Choice 3

I would like to merge Column C - D to let it read 'Choices of Lecturers' instead of Choice 1/2/3.

Can I know where am i supposed to do the code in like 'Page_Load' and how do I code it?



View Full Details...............................

Multi step, non sequential form

Multi step, non sequential form

I need to create a from with multiple steps.

Depending on the answers of the user, a following step is loaded.

What would be the best approach to tackle this problem?

View Full Details...............................

out-of-range datetime value

out-of-range datetime value
Hi there

I wrote a web application and it was working fine with no errors in my local server and the live server. My system lost its data and the hard drive got corrupted. So my hard drive was replaced with a new one. When I configure the web application on my new hard drive and run it, it was working ok except for the part that is has date selection on it I get the following error

Exception Type: System.Data.SqlClient.SqlException
Exception Message: The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
Exception Source: .Net SqlClient Data Provider
Exception Target Site: Read

I didn’t change the code or anything; the same version is working on the live server with no issues. I don’t know why it is giving me this error in my machine.

Any ideas??

View Full Details...............................

how do you add script src urls in header with C# code behind

how do you add script src urls in header with C# code behind
basically, how do you add to the page header...



dynamically with the page load event handler.

I know how to add actual script code to the page, with registerClientScriptBlock(), but that is not what i want.

I need to register the script url in the page header, not an actual script block.

Any help appreciated.
Thanks!

View Full Details...............................

Asp.net Code can not download Zip file of more then 12 mb

Asp.net Code can not download Zip file of more then 12 mb

hi ,

There is file server and Webserver.On file server there are several files.Now when I try to

download a Zip file from file server,Zip file is truncated mid-download (usually around 12mb) and therefore unreadable but when I try to download any other file which is not Zip file and which is of same size or even bigger size, then it downloads that file ,I mean to say it is unable to download only Zip file of more than 12 mb.

What could be the possible reason for this.application has been developed using C# ,ASP.net..

code which is downloading is -

private void DownloadFile(string MyFilePath)
{
const int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];

FileStream stream = new FileStream(
MyFilePath,
FileMode.Open,
FileAccess.Read,
FileShare.Read);
try
{

string contentDisposition = string.Format(
"attachment; filename=\"{0}\"",
Path.GetFileName(MyFilePath));
Response.AddHeader(
"Content-Disposition",
contentDisposition);

for (; ; )
{
int bytesRead = stream.Read(buffer, 0, bufferSize);
if (0 == bytesRead)
{
// all done
break;
}
Response.OutputStream.Write(buffer, 0, bytesRead);
}
}
finally
{
stream.Close();
}
}





View Full Details...............................

ASP.Net/General - Value of Variable Changes

ASP.Net/General - Value of Variable Changes
Hello,

I have a form with a variable addNew as Boolean. I have 2 buttons "Add" and Save". I change the valus of addNew in Add button event and make it as True. Focus is on text boxes, I enter date and click on Save button to save the data entered. But in save event method, the value of addNew is False only. Except these 2 places and Page_Load, I am not using addNew anywhere. I can't make out then ho the value of addNew turns to False from True which was lastly set in Add method. I also have a listbox whose AutoPost property is set to True.



' List SelectedIndexChange event
Protected Sub locationsList_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles locationsList.SelectedIndexChanged
' Retrieve data from Datasource
' And show contents in respective text boxes
MsgBox(locationsList.SelectedValue + " Index = " + locationsList.SelectedIndex.ToString)
'dim loc As LocationClass = (LocationClass) locationsList.SelectedItem

End Sub

' Save Button Event
Protected Sub saveBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles saveBtn.Click
If (addNew) Then
' Insert into
locNameTxt.Enabled = False
SqlDataSource1.Insert()
Else
'Update Record
SqlDataSource1.Update()
End If
addNew = False
End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
' Want the values to set only once
If (Not Page.IsPostBack) Then
addNew = False
locationsList.SelectedIndex = 0
End If
End Sub

' Add button Event
Protected Sub PrepareToAdd(ByVal sender As Object, ByVal e As EventArgs) Handles addLocBtn.Click
addNew = True
locNameTxt.Enabled = True
locNameTxt.Focus()
Return
End Sub

I also want to retrieve data from sqldatasource on list's indexchange. I can retrieve the index number and field value. Can I retrieve that row from the datasource. The select statement is "Select * from Locations"

Would be glad if anyone can help me out. Any help is appreciated.

Thanks



View Full Details...............................

ValidateInput() but not on forms?

ValidateInput() but not on forms?

Hi all,

I am using ValidateInput() to check that my querystrings and cookies are not subject to malicious attacks. But that function also checks form fields, which I dont want it to do since I allow html code to be entered in text boxes.

Is there a way to make ValidateInput() not check the form input fields?



View Full Details...............................

Where to Add code of Form Closing event

Where to Add code of Form Closing event
Hello,

I have some class variables used in the VB code behind of aspx files and wish to dispose them or make them Nothing on closing of form.

In ASP.NET, we don't have form closing event, then where do I add such code. Form_Unload occurs every time the form is changed/refreshed, etc. I just want to execute the code at the end of the form i.e. closing state. How can I do it?

Thanks,


View Full Details...............................

Date conversion error

Date conversion error

txtDate.Text = DateTime.Now.ToString("dd/MM/yyyy");

i want to store the date in database in the above Indian date format....

Convert.ToDateTime(txtDate.Text);

but after the datetime conversion I got an error Msg at Runtime.how to solve this.............

View Full Details...............................

Isit possible to highlight selected values in a gridview?

Isit possible to highlight selected values in a gridview?
In a gridview, I have got 4 columns.
The goal of this is to highlight the cell that matches the other cell.

An example:

For Each row in the Table
If columnA == L.column1 Then
L.column1 cell change color to yellow
Else If columnA == L.column2 Then
L.column2 cell change color to yellow
Else columnA == L.column3 Then
L.column3 cell change color to yellow
End
Next


A clearer example:
Let's say if:
columnA = Alex
L.column1 = Alex
L.column2 = John
L.column3 = Mary

columnA == L.column1
The result will be that the gridview will have L.column1 cell color change to yellow.

I am using VB 2008, asp.net. SQL database is inside VB 2008.

Plese do help!



View Full Details...............................

chrome file upload control doesn't show correctly

chrome file upload control doesn't show correctly

the File control [ ] works in all browsers But when you use it with Chrome, it doesn't show up the text box and shows blank file name if you don't choose any file or click cancel.

Does any one know, how to fix this issue with chrome?

Thanks!!



View Full Details...............................

Help needed with passing a query string into a mssql db

Help needed with passing a query string into a mssql db

newbie help needed

im new to asp.net (vb)

can anyone help me ive written some code (see below) to pull some vars from a string in the url

i needed to send these to a mssql database any ideas how i do this, any code would be much appreciated

thanks,

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim campaignQS As String
Dim urlQS As String
Dim voteQS As String

If Not HttpContext.Current.Request.QueryString("var2") Is Nothing Then
campaignQS = HttpContext.Current.Request.QueryString("var2")
End If


If Not HttpContext.Current.Request.QueryString("var3") Is Nothing Then
urlQS = HttpContext.Current.Request.QueryString("var3")
End If


If Not HttpContext.Current.Request.QueryString("var") Is Nothing Then
voteQS = HttpContext.Current.Request.QueryString("var")
End If


View Full Details...............................

Get file size of uploaded file

Get file size of uploaded file

Hi..

I have this script to upload files:

"FileUpload1" runat="server">

Protected Sub UploadBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnAttach.Click

If FileUpLoad1.HasFile Then

FileUpLoad1.SaveAs(strFilePath_Tmp)

End If

End Sub

How can I check the file size before upload?

Thanks.



View Full Details...............................

Need URGENT help with Gridview not displaying records that have NULL values in db

Need URGENT help with Gridview not displaying records that have NULL values in db

Hi...

I have a dropdown and 3 textboxes at the top of the page. Dropdown is for school, then textboxes for FirstName, LastName, and Address... I have one button that when clicked uses those criteria to pull data back from one Students table in the database.

The parameters are School = @School, FirstName LIKE @FirstName + '%', LastName LIKE @LastName + '%', Address LIKE '%' + @Address + '%'.

In the database, there are records where the Address field has NULL values.

The gridview will NOT pull those records into the gridview display. If I put a value in for the Address field in that record, it shows up fine.

NULL is only placed in the Address field after an update has occurred on that record. The database in its initial state had all Empty Address fields for all records, so it pulls up most records, just NOT those that have been Updated and a NULL value was pushed into that field.

I have tried putting a Default Value in the Address parameter, but that will not work...

I have also tried putting WHERE ((Address LIKE '%' + @Address + '%') OR (Address IS NULL)), but that is not a real solution b/c if I actually have an address im wanting to use for search criteria it will pull up all those records that have an Address field that IS NULL along with records that have address criteria that matches what I typed in the textbox.

How do I resolve this, please?


View Full Details...............................

Set OnClick Event with a string Parameter on LinkButton from ListView ItemDataBound (x_X)

Set OnClick Event with a string Parameter on LinkButton from ListView ItemDataBound (x_X)

Hello,

I got a label on my webform that i would like to rename when a product is selected inside a ListView.



DataSourceID="ProductsDataSource" GroupItemCount="5"
runat="server" onitemdatabound="ProductsListView_ItemDataBound1">
...









In code behind, on ListViewItemDatabound event, i did this :


((LinkButton)e.Item.FindControl("LinkButton1")).Click += new EventHandler(linkButton_Handle); //adding the new OnClick event to replace the default one

string str = DataBinder.Eval(DataItem.DataItem, "Prod_Nom").ToString(); // define a string who will be the Label1.text later on LinkButton_Handle event

((LinkButton)e.Item.FindControl("LinkButton1")).Attributes.Add("OnClick", String.Format("javascript:{0};", this.ClientScript.GetPostBackEventReference(this, str))); // adding the parameter to the javascript on LinkButton OnClick event


Here's the html i get from the output for example :


First problem : linkButton_Handle is never called (maybe linkbutton1 is constructed before ?)

Second problem : how can i use my 'Agenda 2009' parameter to set my Label1.text with that parameter ?


Starting to drive in crazy, Thanks for help.


View Full Details...............................

IF / NOTHING statement Time issue

IF / NOTHING statement Time issue

Good morning,

My arguments with the coding i've inherited continue, and being a monday morning my head isn't quite ready for it yet....

Quite straightforward, I've added to our checkout system an extra field in the INSERT commands to add the order date and time to the database, so it can print out on the customer's invoice.

So I figured on (the printed invoice) using a simple IF command to check if the order has a time on it in the first place, and if not, just produce a default value. Trouble is, i get a BC30035 Syntax error, even though it looks ok to me!!!

Code:
Line 196: If objRS.Fields("OrderTime").Value Is Nothing
Line 197: then OrderTime = "2009-01-01 00:00:00"
Line 198: Else OrderTime = objRS.Fields("OrderTime").value
Line 199: End Ifas



View Full Details...............................

Object reference not set to an instance of an object error

Object reference not set to an instance of an object error

(mods, you might want to make this a sticky)

Considering the large number of "Object reference not set to an instance of an object" errors abound, I figured its my "public duty" to give the main reasons, and thus... reduce the number of superflous threads created on the matter:

Cause one:

Not declaring variables!

Yes, I know it sounds obvious, but MAKE SURE that you've explicity declared the variable, and don't forget to use the appropriate scope!

One common mistayke is when working with Codebehind Classes, consider:


View Full Details...............................

Custom and Required Field Validator

Custom and Required Field Validator

Can we add both custom and required field validator to a single control. I need to do validate the control as required field in some scenarios and custom validate the control everytime.

Thanks


View Full Details...............................

how to display vowels in a given string??

how to display vowels in a given string??.

hi all i want to display vowels and consonants in a given string how to do this can anyone help me?? i have taken a txtbox and btn if the btn is pressed it has to show vowels and consonants separately.thanks

View Full Details...............................

Multiple websites and a "common" set of forms

Multiple websites and a "common" set of forms

Hello,

I have multiple .Net websites. I have a set of forms that manage the user profile (though for the purposes of this question it could be for anything). This set of forms is the same for every .Net website except for the Master forms. The form uses the same sql database, the format of the form is the same, same code behinds, etc.

Instead of creating seperate forms for each website, I would like to create the forms one time, keep the forms in one place and then direct the .Net websites where to go for the form (html and all).

What method should I use to do this? I have looked at web services, but that still leaves me "managing" the data in each Website. I am thinking user controls and embeding the object, but was wondering if this is the best idea. Maybe using DLLs to package the forms and code into a unit for distribution would be fine also.

If I could just get pointed in the right direction, I can figure everything else out.

Thanks, Charlie.



View Full Details...............................

Monday, August 17, 2009

RowUpdating doesn't work. Please help!

RowUpdating doesn't work. Please help!

Hi all,

I have a problem with RowUpdating event handler. When i click update button,it doesn't change the old values with new ones. no change in database too. This is the code behind:

protected void EditGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)

{

SqlDataSource source = EditGridView.DataSource as SqlDataSource;

DataSourceSelectArguments args = new DataSourceSelectArguments();

DataView view = source.Select(args) as DataView;

DataTable dt = view.ToTable();

GridViewRow row = EditGridView.Rows[e.RowIndex];

dt.Rows[row.DataItemIndex][2] = ((TextBox)(row.Cells[3].Controls[0])).Text;

EditGridView.EditIndex = -1;

EditGridView.DataBind();

}


I tried to bind SqlDataSource before DataBind like this but didn't work.

EditGridView.DataSource = dt;

View Full Details...............................

Problem with an datagrid solution

Problem with an datagrid solution


Hi All,

I have written an form with several dropdownlists.

I want to show only the things (in an datagrid) of which the user has selected a Item in one of the available dropdownlists. I have written a query of which I think should do the trick, but instead I see nothing :(

Maybe I have forgotten something, but I can't see what. Perhaps some of you may have a idea? Thanks in advance:

The SQL query of the datagrid:

SELECT BandenMerk, Bandenwinter, BandenBreedte, BandenSerie, BandenInch, BandenSpeed, BandenLoad, BandenProfiel, BandenBestelcode, BandenBrutoST, BandenMarge, BandenNettoST FROM Bandenexport WHERE (@bandenmerk IS NULL OR bandenMerk = @bandenmerk) and (@bandenwinter = Null OR bandenwinter = @bandenwinter) and (@BandenBreedte = Null or BandenBreedte = @BandenBreedte) and (@BandenSerie is Null or BandenSerie = @BandenSerie) and (@BandenInch is Null or BandenInch = @BandenInch) and (@BandenSpeed is Null or BandenSpeed = @BandenSpeed) and (@BandenLoad is Null or BandenLoad = @BandenLoad) and (@BandenProfiel is null or BandenProfiel = @BandenProfiel)

The parameterselection :

>
<asp:ControlParameter ControlID="lstMerk" Name="bandenmerk" PropertyName="SelectedValue" DefaultValue="Null" />
<asp:ControlParameter ControlID="lstwinter" Name="bandenwinter" PropertyName="SelectedValue" DefaultValue="" />
<asp:ControlParameter ControlID="lstbreedte" Name="BandenBreedte" PropertyName="SelectedValue" DefaultValue="" />
<asp:ControlParameter ControlID="lstinch" Name="BandenSerie" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="lstinch" Name="BandenInch" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="lstspeed" Name="BandenSpeed" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="lstLoad" Name="BandenLoad" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="lstProfiel" Name="BandenProfiel" PropertyName="SelectedValue" />
SelectParameters>

properties of the gridview:

<

asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="BandenView">

If nothing is selected by the user, all records should bee shown.


View Full Details...............................


how to open new window using GridButtonColumn?

how to open new window using GridButtonColumn?

THis is on telerik controls. I need this on C# and asp.net. I am trying to use gridbuttoncolumn when image is clicked new window will open up.. target= _new is not supported how can I do that? I tried this below code but it is saying are you missing assemblies it is not found for underlined words, TableCell and ImageButton

<radG:GridButtonColumn ButtonType="ImageButton" ..

protected void RadGrid_OnDataBound(object sender, EventArgs e)
{
foreach (GridDataItem item in rgManageEvents.Items)
{
if (item.ItemType == GridItemType.Item
|| item.ItemType == GridItemType.AlternatingItem)
{
TableCell cell = item.Cells[2];
Control ctl = cell.Controls[0];
if (ctl is ImageButton)
{
(ctl as ImageButton).Attributes.Add("onclick", "document.forms[0].target= '_new';return true;");
}
}
}
}


View Full Details...............................