|
Hi
how to get no of month between 2 dates iin c#
Thanks ,
Amit
|
|
|
|
|
|
thanks ,
I have created my own logic
int monthsApart = 12 * (DateTime.Now.Year - startDateTime1.Year) + DateTime.Now.Month - startDateTime1.Month;
i hope this will help others
Thanks
|
|
|
|
|
Great. How long did you spend creating something that already exists? Why not learn to use the tools you have.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
hi iam using asp.net with c#
in my form there is file upload control to browse and get the image and there is dropdownlist control from which i have to select the items ,
on selecting the items from dropdownlist onselectedindex changed event ,the file upload control is becomming empty how to handle this situation
can you give example which helps me
|
|
|
|
|
Do you set the value of the dropdownlist in (for example) the OnLoad event?
if (!IsPostback)
{
}
|
|
|
|
|
You can place the dropdown list and the control you want to change onselectedindexchanged in update panel control, but place the upload control outside the update panel.
it will surely work for you.
|
|
|
|
|
thanks for the code project team .....
this logic helps me
|
|
|
|
|
selected indexchange event fires twice when selection changes i.e one event for deselecting the previous item and other for selecting the new item.
you may be refreshing the fileupload control in selected index change event,if so,make sure file upload path is empty before refreshing.
|
|
|
|
|
Hi All,
I have got this date 4/1/2010 12:00:01 AM from my text box and i converted it into the Date time (this date is April)
i know the today date time using Datetime.now
So i want all end date of month in the following format
30 Apr
31 May
thanks
amit
|
|
|
|
|
You must specify a date format you want to use to display the date.
This should do the trick :
DateTime.Now.ToString("d MMM yyyy hh:mm:ss");
|
|
|
|
|
following will displat the last date of the present month.
day(DateSerial(Year(datetime.Now), Month(datetime.Now), 0))
|
|
|
|
|
You can use DateTime.Now.Month to return an int representation of the month. You can pass this to a function to switch on for the month name, IE:
switch(month)
{
case 1:
return "January";
case 2:
return "Feburary";
}
|
|
|
|
|
Hi all,
In my application i am displaying Amount field in a grid view. which is money type in data base.my problem is when i m displaying it,it shows 4 numbers after decimal like ('45.0000').but i want to display only 2 places after decimal ('45.00').In sql query analyser it shows correctly.I have already used round function but still it is not working.
Any suggestions?
|
|
|
|
|
Hi there,
is it a bound field? Then you could use the DataFormatString property.
In a custom/template field, you could output your value as string and use string.Format with
a fitting format string (like here).
|
|
|
|
|
i am using Label to diplay it in a ItemTemplate.
|
|
|
|
|
Hi,
then here is an example on how to do it. Just replace the "((double)0.123)" by your variable and modify the rest according to your needs:
<ItemTemplate>
<asp:Label runat="server" Text='<%# ((double)0.123).ToString("N") %>'></asp:Label>
</ItemTemplate>
|
|
|
|
|
|
Please try as below
Textbox.Text.ToString("0.00");
Hope this will work for you.
|
|
|
|
|
I have a div with a background image in my master page, but I can't see this image in the inherited pages.
maybe it happens because the master page and the pages are placed in different directories...
what can I do?
|
|
|
|
|
Try to specify the background image path using ResolveURL on master page like this
src="<%=ResolveUrl("~/images/test.png")%>"
|
|
|
|
|
I have a Gridview in my form and I use SqlDataSource to fill the Grid. I have an Edit button also in the Gridview to Edit data.
The problem is while clicking on Edit, the dropdownlist in the Gridview
is not displaying the item selected, but going to the first item of the dropdownlist. How should I make the selected item
displayed while click on Edit?
Please find below my code:
<asp:GridView ID="grdDTCCRics" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False"
DataKeyNames="REDCODE"
OnRowDeleted="grdDTCCRics_RowDeleted"
OnRowUpdated="grdDTCCRics_RowUpdated"
OnRowUpdating="grdDTCCRics_RowUpdating"
OnRowEditing="grdDTCCRics_RowEditing"
OnPageIndexChanged="CmdCancel_Click"
DataSourceID="SqlDataSource1">
<RowStyle Height="20px" HorizontalAlign="Center" VerticalAlign="Middle" />
<EmptyDataRowStyle Height="20px" HorizontalAlign="Center" VerticalAlign="Middle" />
<Columns>
<asp:BoundField DataField="REDCODE" HeaderText="REDCODE" ReadOnly="True" SortExpression="REDCODE" />
<asp:TemplateField HeaderText="RIC" SortExpression="RIC">
<EditItemTemplate>
<asp:TextBox ID="RICTextBox" runat="server" Text='<%# Eval("RIC") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="RICLabel"
runat="Server" Text='<%# Eval("RIC") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="REGIONCODE" SortExpression="REGIONCODE">
<EditItemTemplate>
<asp:DropDownList ID="RegionCodeList" runat="Server">
<asp:ListItem Text="AM" Value="1"></asp:ListItem>
<asp:ListItem Text="US" Value="2"></asp:ListItem>
<asp:ListItem Text="EU" Value="3"></asp:ListItem>
<asp:ListItem Text="JP" Value="4"></asp:ListItem>
<asp:ListItem Text="AS" Value="5"></asp:ListItem>
<asp:ListItem Text="OF" Value="6"></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblcountry" runat="server" Text = '<%# Eval("REGIONCODE") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" ValidationGroup="Upd" ButtonType="Button" HeaderText="EDIT" >
<ControlStyle Height="22px" Width="50px" />
</Columns>
</GridView>
When I tried to get the editrowindex, the object lstRegion is coming as null in the rowEditing eventhandler. Any idea how to display it properly? Please help.
Thanks
meeram395.
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
Hi,
maybe there is a simpler solution, but you could use the rowdatabound event
of your gridview and set the index of the dropdown there appropriatly (if in edit mode).
Here is an example (which is using c1gridview, just replace it by the microsoft one and
check the if conditions, they may be slightly different)
protected void grdRoomTypes_RowDataBound(object sender, C1.Web.UI.Controls.C1GridView.C1GridViewRowEventArgs e)
{
if (e.Row.RowType == C1.Web.UI.Controls.C1GridView.C1GridViewRowType.DataRow)
{
if ((e.Row.RowState & C1.Web.UI.Controls.C1GridView.C1GridViewRowState.Edit) > 0)
{
TimeSchemeEditor editor = (TimeSchemeEditor)e.Row.FindControl("timeSchemeEditor");
editor.TimeScheme = (ServiceDirectoryRoomTypeItem)e.Row.DataItem;
}
else
{
TimeSchemeViewer viewer = (TimeSchemeViewer)e.Row.FindControl("timeSchemeViewer");
viewer.TimeScheme = (ServiceDirectoryRoomTypeItem)e.Row.DataItem;
}
}
}
|
|
|
|
|
Thanks for the reply. However that code is not working. Following is my RowDataBound Event:
protected void grdTCCRics_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if ((e.Row.RowState & DataControlRowState.Edit) > 0)
{
Label lblRegion = (Label)e.Row.FindControl("lblcountry");
if (lblRegion != null)
{
DropDownList ddlRegion = (DropDownList)e.Row.FindControl("RegionCodeList");
if (ddlRegion != null)
{
ddlRegion.SelectedItem.Text = lblRegion.Text.Trim();
}
}
}
}
}
The Label control lblRegion is coming as null. So how will I get the value? Please help.
Thanks
meeram395.
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
I guess in your markup, you have an edititemtemplate and an itemtemplate, is that right?
In your rowdatabound event, it depends on the current rowstate, which controls exist and which not. For example, if you have a label in your itemtemplate and a dropdown in your
edititemtemplate, then the label will be null if rowstate == edit and the other way around.
So first check if RowState == Edit and then find your dropdown. you will not find the
controls shown during "view" rowstate (dont read viewstate:P).
GL
|
|
|
|