Monday, August 10, 2009

FAQs in asp.net

I feel its better to start my posting with some FAQs in asp.net which will help to save the precious time of people in the same field.

How can we only display header or footer when there is no data to bind to a grid view ?

Can add a dummy record and bind it to the grid and then clear all the rows

Eg:

gvFacilities.DataSource = new List{
new PL_FACILITy
{
ID = 0,
Quantity = 0,
QuantityApplicable = false,
Name = string.Empty,
TypeID = 0
}};

gvFacilities.DataBind();
gvFacilities.Rows[0].Cells.Clear();

When bind data to a drop down using cascading drop down list,if we get method 500 error,possible errors(solutions)will be

  1. May be missing the Script Service attribute to the web service -[System.Web.Script.Services.ScriptService]
  2. May be missing the Web Method attribute to the web service method-[WebMethod]
  3. Web Service method definition may not tally with method signature specification of the cascading drop down list
  4. Content volume retrieved from the database may be high.
  5. May be some errors with acceessing the data from database(For example may be a problem Sql connection opening and closing ).
  6. May be the path specified to the web service incorrect.

If you get this method 500 error,better way to check is,put a break point in the web service method and need to check whether it hits the break point.If it doesn't hit,then possible errors will be 1,2,3 and 6.(Check the above mentioned options).Otherwise,If it hits,then possible causes will be 4,5.

And one more thing,when you use context key,the web service method signature will be different and you need to enable context key in the Cascading dropdown design.

UseContextKey-true/false