Sunday, September 30, 2007

using a populated dataset (one row of data) display data ina table

dsPickListDetails = objPackingList.GetPickListDetails(PickListId);
lblHeight.Text = dsPickListDetails.Tables[0].Rows[0]["Height"].ToString();

Saturday, September 29, 2007

Bind dorop down to dataset object easyly

private void BindDropDowns(string dataTextField, string dataValueField, DataSet ds, DropDownList dropDownListID)
{
try
{

dropDownListID.DataSource = ds;
dropDownListID.DataTextField = dataTextField;
dropDownListID.DataValueField = dataValueField;
dropDownListID.DataBind();
}

catch (Exception ex)
{

}

}
//To call the method


BindDropDowns("Id", "Id", dsApprovedPickList, ddlPickListNo);

Example of How to join 3 tables using inner join

alter PROCEDURE uspGetPickListDetails
@PickListId int
AS
BEGIN
SELECT PL.Weight, PL.Length,PL.Height, PL.Width, f.Carrier_Name, f.Phone,
s.SO_No, s.BillingAddress, s.ShippingAddress
FROM PickList pl inner join FreightCarriers f
on PL.ShippingMethod=f.Carrier_No inner join salesorder s on
PL.Sales_Order_No=s.Sales_Order_No where PL.Id=@PickListId
END

Friday, September 28, 2007

Sql Query Which give ID not in another table

SELECT PL.id from PL
WHERE PL.Id
not in(select PS.ListNo from PS)

Thursday, September 27, 2007

Wednesday, September 19, 2007

Format date fome the database (not front end)

(cast(year([Due_Date]) as varchar)+'-'+cast(month([Due_Date]) as varchar)+'-'+ cast(day([Due_Date]) as varchar)) AS [Due_Date],

Monday, September 17, 2007

Assign default value to a object is when assign default value to object is when dbnull type value is incoming

//this help you to assign default value to object is when giv en dbnull type
objPackingSlip.sent_To = (dr["sent_To"]!=DBNull.Value)? Convert.ToInt32(dr["sent_To"]):0;

Implement mail functionality link using a hypelink

//just a little code but somes may time usefull

lnkSupport.NavigateUrl = "mailto:support@Abcdef.com";

Thursday, September 13, 2007

Getting Values from asp.net data grid view

//fist you should define keyvalue filed with seperated commas
row["Product_No"] = gvPOReceivingItems.DataKeys[i].Values[0].ToString();

Friday, September 7, 2007

Send the mail using Threading

string sException;
sException = ex.ToString();
SendEmail myMail = new SendEmail();
myMail.SendEmailError(sException + " Time: " + DateTime.Now.ToString());
Thread thread = new System.Threading.Thread(new ThreadStart(sendMailFunction));
//SendMailWithProjectDetails(workOrderId, projectDetailMail)));
thread.Priority = ThreadPriority.Highest;
thread.Start();
Response.Redirect("DefaultErrorPage.aspx");

Thursday, September 6, 2007

Handling row edit Event in dataGrid


protected void gvProductionDocumentList_RowEditing(object sender, GridViewEditEventArgs e)

{

Response.Redirect("WashingEdit.aspx?Id=" + gvProductionDocumentList.DataKeys[e.NewEditIndex].Value, false);

}

Wednesday, September 5, 2007

Format DataGrid data format without time

//add this text from html view
DataFormatString="{0:dd/MM/yyyy}" HtmlEncode="False"