Tuesday 9 October 2012

Nulll in GridView EVAL Calling ServerSide Method In Item Template

<asp:GridView ID="GridView1" runat="server" 
              DataSourceID="SqlDataSource1" 
              AutoGenerateColumns="false">

<Columns>
<asp:BoundField ShowHeader="true" DataField="ID" 
                              HeaderText="ID" />
<asp:TemplateField HeaderText="Name">

<ItemTemplate>
<asp:Label ID="Label1" runat="server" 
           Text='<%# CheckNull(Eval("Name")) %>'>
</asp:Label>

</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Location">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" 
           Text='<%# CheckNull(Eval("Location")) %>'>

</asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView> 
 --------------------------------------------------------------------------
.CS PAGE 
protected string CheckNull(object objGrid)
    {
        if (object.ReferenceEquals(objGrid, DBNull.Value))
        {
            return "No Record Found";
        }
        else
        {
            return objGrid.ToString();
        }
}

16 comments:

  1. http://www.questpond.com/

    ReplyDelete
  2. http://www.dotnetobject.com/expage.php?exurl=http://simasc.com/attachments/046_SampleInterviewQuestionBook%281%29.pdf

    ReplyDelete
  3. http://www.kau.edu.sa/Files/830/Files/55533_C_Sharp_Programming.pdf

    ReplyDelete
  4. http://stackoverflow.com/questions/8473671/mvc3-validation-check-if-property-values-differ

    ReplyDelete
  5. http://stackoverflow.com/questions/10586007/how-to-add-maxlength-for-textareafor-in-view-using-razor-engine

    ReplyDelete
  6. http://miroprocessordev.blogspot.in/2012/04/generic-checkboxlist-in-aspnet-mvc-3.html

    ReplyDelete
  7. http://azadehkhojandi.blogspot.in/2011/07/when-you-have-list-of-enum-in-your.html

    ReplyDelete
  8. http://avidyarthi.blogspot.in

    ReplyDelete
  9. http://blog.weareon.net

    ReplyDelete
  10. http://www.aboutonlinetips.com/how-to-split-csv-file/

    ReplyDelete
  11. http://www.dotnet-tricks.com/Tutorial/mvc/9KHW190712-ViewData-vs-ViewBag-vs-TempData-objects-in-mvc3-razor.html

    ReplyDelete
  12. http://msdn.microsoft.com/en-us/library/gg508808%28v=vs.98%29.aspx

    ReplyDelete
  13. http://www.codeproject.com/Articles/260177/Custom-Validation-Attribute-in-ASP-NET-MVC3

    ReplyDelete
  14. http://www.upscaleandposh.com/products/A-Love-Dynamic-Duo.html

    ReplyDelete
  15. http://www.smartdigitizers.com/general/reading-data-from-excel-by-using-sql-statements-odbc/

    http://www.mssqltips.com/sqlservertip/1540/insert-update-or-delete-data-in-sql-server-from-excel/

    ReplyDelete
  16. public ActionResult Index()
    {
    ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";

    return View();
    }

    public ActionResult About()
    {
    ViewBag.Message = "Your app description page.";

    return View();
    }

    public ActionResult Contact()
    {
    ViewBag.Message = "Your contact page.";

    return View();
    }

    ReplyDelete