|
I would suggest setting the Date format as a user preference in your application as opposed to allowing the user to update the data in the database. This would be the easiest way to allow this change on your page and would also keep your database from having multiple date values. Here is an article that may assist you in setting up application/user settings.
http://msdn.microsoft.com/en-us/library/aa730869(VS.80).aspx[^]
Hope this helps.
Matthew Vass
QA Analyst
mvass@hostmysite.com
http://www.hostmysite.com?utm_source=bb[^]
|
|
|
|
|
Hello Matthew,
this is not what I am looking for.
There is only 1 setting for al users. It is not attached to user but to datatype.
Any one else who knows how to find the link between datarowview value and tablecell value and the filling on the fly of the dataformatstring of the gridview?
In Word you can only store 2 bytes. That is why I use Writer.
|
|
|
|
|
Having it fixed
This is the trick
1. Determine for each gridviewcolumn its headertext
2. Determine for each cell in the row.cells if the cell.ContainingField.HeaderText equals the headertext found in the previous gridviewcolumn
3. If the value of an item in the array of the datarowview with (yeah I know it can be buggy) the cell.text value you have found it
Than determine the type of the dataRowView[x] and fill cell.text with the formatstring in the Database.
Anyone a better solution ?
see my code:
public static GridViewRow MaakGridViewRowOp(GridViewRow row)
{
GridView grid = (GridView)row.NamingContainer;
DataRowView dataRow = (DataRowView)row.DataItem;
foreach (DataControlField column in grid.Columns)
{
foreach (DataControlFieldCell cell in row.Cells)
{
if (column.HeaderText.Equals(cell.ContainingField.HeaderText)
&& !String.IsNullOrEmpty(column.HeaderText))
{
for (int celwaarde = 1; celwaarde < dataRow.Row.ItemArray.Length; celwaarde++)
{
if (cell.Text.StartsWith(dataRow[celwaarde].ToString(),
StringComparison.OrdinalIgnoreCase))
{
if (dataRow[celwaarde].GetType().Equals(Type.GetType("System.DateTime")))
{
DateTime datum = Convert.ToDateTime(dataRow[celwaarde]);
cell.Text = datum.ToString(MSBNZBLL.ParameterString.
SysteemParameters.GetParameterAsString("DatumTijdFormat"));
}
else if (dataRow[celwaarde].GetType().Equals(Type.GetType("System.Decimal")))
{
Decimal getal = Convert.ToDecimal(dataRow[celwaarde]);
cell.Text = getal.ToString(MSBNZBLL.ParameterString.
SysteemParameters.GetParameterAsString("VerwerkteMetingFormat"));
}
else if (dataRow[celwaarde].GetType().Equals(Type.GetType("System.Int32")))
{
Decimal getal = Convert.ToDecimal(dataRow[celwaarde]);
cell.Text = getal.ToString(MSBNZBLL.ParameterString.
SysteemParameters.GetParameterAsString("VerwerkteMetingFormat"));
}
else if (dataRow[celwaarde].GetType().Equals(Type.GetType("System.Int16")))
{
Decimal getal = Convert.ToDecimal(dataRow[celwaarde]);
cell.Text = getal.ToString(MSBNZBLL.ParameterString.
SysteemParameters.GetParameterAsString("VerwerkteMetingFormat"));
}
else if (dataRow[celwaarde].GetType().Equals(Type.GetType("System.Int64")))
{
Decimal getal = Convert.ToDecimal(dataRow[celwaarde]);
cell.Text = getal.ToString(MSBNZBLL.ParameterString.
SysteemParameters.GetParameterAsString("VerwerkteMetingFormat"));
}
break;
}
}
}
}
}
return row;
}
In Word you can only store 2 bytes. That is why I use Writer.
|
|
|
|
|
Hi
I am developing an windows service that sends email notifications to all not activated members and not published users. I tested my email notifications with a sample windows application but the same notifications are failing in my service. But I put all of the dlls in the same directory as my service exe file.
Here is the piece that fails:
SMPTServer = this.gs.SMTPServer;
if (userEmail != "" && userEmail != null)
{
//Send Email Notification
doXtop.Framework.Messaging.Message msg = new doXtop.Framework.Messaging.Message(); -- it fails here, but this works with my windows test application.
}
The service logged with "Object reference not set to an instance of an object."
Can any give me ideas, how can I solve this.
modified on Wednesday, March 18, 2009 12:47 PM
|
|
|
|
|
You might get the NUll reference because you first check if userEmail = ""
It is more wise to create the next IF
if (null != userEmail && !userEmail.Equals(String.Empty))
|
|
|
|
|
Hi
I checked it, it was not problem in the line of code that I posted but its the problem with
doXtop.Framework.Messaging.Message msg = new doXtop.Framework.Messaging.Message();
This is strange. For me the following line of code is working but the above one is not working:
doXtop.Framework.Messaging.Message.SendEmail("info@doXtop.com", userEmail, subject, message, SMTPServer);
|
|
|
|
|
can/will you show the code of the messaging class?
|
|
|
|
|
Here is the code of my messaging class:
public class Message : IDisposable
{
public Hashtable HtEmails;
public HttpContext Context;
public bool ThreadExecution = false;
public string From;
public string Subject;
public string SmtpClient;
public string Body;
public string EmailProvider;
public string Username;
public string FullName;
public string ActivationMessage;
public Guid UserId;
public GlobalSettings gs;
public Uri Url;
public string ApplicationPath;
public enum Box
{
Inbox,
Outbox
}
DataAccess _da;
DataSource _ds;
public Message()
{
_da = new DataAccess();
_ds = new DataSource(_da);
ConfigurationProvider cp = new ConfigurationProvider();
gs = cp.GlobalSettings;
}
public bool InsertMessage(string from, string to, string subject, string body, string senderIPAddress)
{
try
{
SqlParameter[] _params = {
new SqlParameter("@MessageId", Guid.NewGuid()),
new SqlParameter("@From", from),
new SqlParameter("@To", to),
new SqlParameter("@Subject", subject),
new SqlParameter("@Body", body),
new SqlParameter("@SenderIPAddress", senderIPAddress)
};
_ds.ExecuteNonQueryProcedureProxy("InsertMessage", _params);
return true;
}
catch (Exception e)
{
EventLog.WriteEntry("WideDocs", e.ToString(), EventLogEntryType.Error);
return false;
}
}
}
|
|
|
|
|
I believe your problem is this:
public Hashtable HtEmails;
public HttpContext Context;
public bool ThreadExecution = false;
public string From;
public string Subject;
public string SmtpClient;
public string Body;
public string EmailProvider;
public string Username;
public string FullName;
public string ActivationMessage;
public Guid UserId;
public GlobalSettings gs;
public Uri Url;
public string ApplicationPath;
they are mostly null. Havent you forget the { get; set; } to use them as properties?
You do not use any of these publics in your class and you cannot set them from outside.
In Word you can only store 2 bytes. That is why I use Writer.
|
|
|
|
|
Hi All,
I have a mysql database. I have a web portal in php where users can update personal information which is added and stored in the database. Im building another web app in asp .net which will feed from the same database.
Is there anyway of 'listening' for when updates occur in the database efficently from my asp .net web app?
Im not sure what the best approach is.
Any suggestions much appreciated.
Thanks
Mike
|
|
|
|
|
hardboy111 wrote: Is there anyway of 'listening' for when updates occur in the database efficently from my asp .net web app?
As both the site are sharing the same database then why you are trying to listing? If there is any update in the database from PHP sites, when user refresh or reload the page in ASP.NET he will get the updated data.
Any specific reason to do that?
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
hardboy111 wrote: Is there anyway of 'listening' for when updates
what do you mean by 'listening'. The very nature of web application does not allow you to listen to events on the server, or does it.
One way to try is, since they are sharing the same database, in your asp.net you may want to use AJAX to check for updated periodically. This will be small and quick bursts of status checks. When you detect a change, hen you refresh your asp.net pages to fetch updated data.
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
im using a COMET approach. Hence if a update occurs I want to be able to push the update down to the web browser without any request from the client.
Polling isnt what I want to do.
|
|
|
|
|
1) does webparts use sql server 2008 database??? with visual studio 2008?
2) if i use webparts then will i have to face some browser compatibility issues??
Government Dyal Singh College Lahore.
|
|
|
|
|
Ans 1 .. No You can use any Database you want.
Ans 2. Webparts in Sharepoint runs best in IE. But you can create web parts that may run in other browsers too. Thats not a problem
|
|
|
|
|
Hi All
Please help, here us the scenario.
I get Source and Source code from the database.
I assign Source to the Text property of the DropDownlist and I assign SourceCode to the Value property of the same DropDownList.
What I want to do is that when you select an item from the DropDownlist, I want take the Value for that Item and do some calculations and keep the selected item shown on the dropDownList.
The problem is that..if the selected item has something eg 2 for the Value the application works fine, but if the Value property for that item in null the dropdown display the first item in the list.
It should display the selected item..it only do this if there is something in the value property.
Here is my code, that populates the dropdownlis.
drpDepot.DataSource = ds;
drpDepot.DataTextField = "SourceName";
drpDepot.DataValueField = "SourceCode";
drpDepot.DataBind();
drpDepot.Items.Insert(0, new ListItem(string.Empty, string.Empty));
Please help, I don’t know what is the problem. Please help.
Thank you in advanced
MP
|
|
|
|
|
khuzwayom wrote: What I want to do is that when you select an item from the DropDownlist, I want take the Value for that Item and do some calculations and keep the selected item shown on the dropDownList.
Please put the code for this section.
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Hi
Thanx for the reply. Here is my code
_kilometers = Convert.ToDouble(txtKM.Text);
_value = drpDepot.SelectedValue.ToString().Trim();
if (_value != "")
{
_value4 = double.Parse(_value);
_transportCost = _kilometers * _value4;
lblMessage.Text = "Estimated Transport Cost is: £ " + _transportCost.ToString();
}
I suppose after finishing executing it should keep the Item selected displayed...
MP
|
|
|
|
|
khuzwayom wrote: _kilometers = Convert.ToDouble(txtKM.Text);
_value = drpDepot.SelectedValue.ToString().Trim();
if (_value != "")
{
_value4 = double.Parse(_value);
_transportCost = _kilometers * _value4;
lblMessage.Text = "Estimated Transport Cost is: £ " + _transportCost.ToString();
}
What ever you have to done in the else put.
else
{
}
But still i am not able to understand where did you written the code means in which event you are loading the data and checking the value.
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Hi Abhijit
Thanx for the assitance.
I populate the Dropwdown in page_load
if (_value != "")
{
_value4 = double.Parse(_value);
_transportCost = _kilometers * _value4;
lblMessage.Text = "Estimated Transport Cost is: £ " + _transportCost.ToString();
}
else
{
lblMessage.Text = "The Source does not have a value"
}
If the execution got inside the if statement, it works fine, it does the calculation and keep the selected item displayed on the dropdown
but if it went ti the ELSe block, it displays the message but the dropdown displays the fisrt item which i sin index 0.
MP
|
|
|
|
|
Problem looks in Page_Load
Did you checked the ISPostBack while Loading Data on dropdown list.
if(!Page.IsPostBack)
{
}
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Yes, I did.
I think the problem is somewhere else not postback, because if th eproblem was postback it should behave the same way even when an item something in its Value property, but it only misbahes when the item has null/nothing in its Value property.
it's C#
if (!IsPostBack)
{
BindDepots();
}
MP
|
|
|
|
|
Ya got it. . Problem is with If checking
Try this
string _value = drpDepot.SelectedValue.ToString().Trim();
if (!string.IsNullOrEmpty(_value))
{
}
else
{
}
Enjoy
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Hi guys
Before You read this I just wanted to inform you I am using Visual Studio 2003, VB.Net as the codebehind, and running asp.net 1.1
I am currently developing an asp.net webpage where a user can input data, and then it will save that data to a Microsoft SQL Server database. The table in this database that I am saving has an ID field which I use as the primary key. The next bit of information is when the data has been inputted, and submitted it will send an email to a person which would need to view the data. This email that I want to send is a link to the data which was inputted by the user. I was wondering if it is possible to send a link to someone with the ID field of the inputted data in the URL of the link, and then have that person be able to open the link and retrieve data from the database.
Example
www.MyHours.com\timesheet\ will load up a blank timesheet for the user(Lets say his name is John) to fill out. John fills out the data, and that row in the database which has an ID of 1235, Next an email is sent out to the person(lets call this person Mary) , and she needs to view the timesheet. The URL that is sent to here www.MyHours.com\timesheet\id=1235, Then Todd fills out the data, and a new row in the database is created with an ID of 1236, and another link is sent to Mary With the url www.MyHours.com\timesheet\id=1236 which she can then click on, and view the data Todd had inputted.
If anyone knows how to do this or can just point me in the write direction on how to do this it would be greatly appreciated.
|
|
|
|
|
you can reuse the blank timesheet page to reload user data when they pass you an id. Instead of showing a blank page, query your database and load the data in the page.
Request.QueryString[^]
Ragonastick wrote: www.MyHours.com\timesheet\id=1235,
this needs to be www.myhours.com\timesheet?id=1235
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|