Why do I get a blank page when I click the linkbutton in the Datagrid, I am also handling PostBack on the page? The ItemCommand Event does not seem to trigger
You must have set the EnableViewState property of DataGrid to false
Why do I get System.Data.DataRowView/System.Data.Common.DbDataRecord as the item in a dropdownlist
This is probably because you have not set the DataTextField/ DatavalueField property of the dropdownlist. VB.NET ’.. DropDownList1.DataSource = ds.Tables(0) DropDownList1.DataTextField = ‘CategoryName’ DropDownList1.DataValueField = ‘CategoryId’ DropDownList1.DataBind() C# //.. DropDownList1.DataSource =ds.Tables[0]; DropDownList1.DataTextField = ‘CategoryName’; DropDownList1.DataValueField = ‘CategoryId’; DropDownList1.DataBind();
How can I fix error message ‘Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount'
There are two approaches to fix this error: Set the CurrentPageIndex = 0 when you bind data in the Page_EventHandler Allow the error to occur and then catch it in a try block resetting the index to 0 and rebinding the grid VB.NET try ’Bind the Data catch ex as ArgumentOutOfRangeException DataGrid1.CurrentPageIndex = 0; ’Bind the Data end try C# try { //Bind the Data } catch(ArgumentOutOfRangeException ex ) { DataGrid1.CurrentPageIndex = 0; //Bind the Data }
How to find the date and time the specified file or directory was last written to
Use namespace System.IO VB.NET dim path as string = Server.MapPath(‘page1.aspx’) Response.Write ( File.GetLastWriteTime(path)) C# string path =Server.MapPath(‘page1.aspx’); Response.Write ( File.GetLastWriteTime(path));
How to convert Color to it’s corresponding Hexadecimal value
VB.NET Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ’Put user code to initialize the page here Response.Write(ToHexColor(Color.Blue)) End Sub Function ToHexColor(ByVal c As Color) As String Return ‘#’ + c.ToArgb().ToString(‘x’).Substring(2) End Function C# private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here Response.Write(ToHexColor(Color.Blue)); } string ToHexColor(Color c ) { return ‘#’ + c.ToArgb().ToString(‘x’).Substring(2); }