How to hide and show data in the DataList
<asp:Datalist runat=’server’ OnItemCommand =’ItemCmd’ id=’Datalist1′ Font-Size=’10pt’ Font-Name=’Verdana’> <ItemTemplate> <asp:LinkButton style=’text-decoration:none’ runat=’server’ id=’btnDetails’ Text=’+’ CommandName=’Show’ Font-Name=’Verdana’ /> <b> <%# DataBinder.Eval(Container.DataItem, ’employeeid’) %> </b> <br /> <asp:label id=’lblEID’ Visible=’False’ runat=’Server’ Text=’<%# DataBinder.Eval(Container.DataItem, ‘Employeeid’) %>’ /> <asp:DataGrid runat=’server’ id=’Datagrid1′ Font-Name=’Verdana’ Font-Size=’10pt’ HorizontalAlign=’Center’ Visible=’False’ Width=’85%’> </ItemTemplate> </asp:Datalist> VB.NET Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then ’Bind data to DataList End If End Sub Private Sub Datalist1_ItemCommand(ByVal source As Object, _ ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) If e.CommandName = ‘Show’ Then Dim EmpIDlabel As Label = e.Item.FindControl(‘lblEID’) Dim strEmpID As String = EmpIDlabel.Text CType(e.Item.FindControl(‘Datagrid1’), DataGrid).DataSource = GetEmpDetails(strEmpID) CType(e.Item.FindControl(‘Datagrid1’), DataGrid).DataBind() CType(e.Item.FindControl(‘Datagrid1’), DataGrid).Visible = True CType(e.Item.FindControl(‘btnDetails’), LinkButton).Text = ‘-‘ CType(e.Item.FindControl(‘btnDetails’), LinkButton).CommandName = ‘Hide’ End If If e.CommandName = ‘Hide’ Then CType(e.Item.FindControl(‘Datagrid1’), DataGrid).Visible = False CType(e.Item.FindControl(‘btnDetails’), LinkButton).Text = ‘+’ CType(e.Item.FindControl(‘btnDetails’), LinkButton).CommandName = ‘Show’ End If End Sub Function GetEmpDetails(ByVal Employeeid As String) As SqlDataReader Const strConnString As String = ‘server=localhost;uid=sa;pwd=;database=northwind’ Dim objConn As New SqlConnection(strConnString) Dim strSQL As String strSQL = ‘SELECT FirstName , LastName ,Title, Address FROM Employees ‘ & _ ‘WHERE Employeeid = @Employeeid’ Dim objCmd As New SqlCommand(strSQL, objConn) Dim paramEmployeeid As SqlParameter paramEmployeeid = New SqlParameter(‘@Employeeid’, SqlDbType.VarChar, 10) paramEmployeeid.Value = Employeeid objCmd.Parameters.Add(paramEmployeeid) objConn.Open() ’Open the connection Return objCmd.ExecuteReader(CommandBehavior.CloseConnection) End Function C# private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if(!Page.IsPostBack ) { //Bind data to Datalist1 } } protected void ItemCmd(object source , System.Web.UI.WebControls.DataListCommandEventArgs e ) { if( e.CommandName == ‘Show’ ) { Label EmpIDlabel =(Label) e.Item.FindControl(‘lblEID’); string strEmpID = EmpIDlabel.Text; ((DataGrid)e.Item.FindControl(‘Datagrid1’)).DataSource = GetEmpDetails(strEmpID); ((DataGrid)e.Item.FindControl(‘Datagrid1’)).DataBind(); ((DataGrid)e.Item.FindControl(‘Datagrid1’)).Visible = true; ((LinkButton)e.Item.FindControl(‘btnDetails’)).Text = ‘-‘; ((LinkButton)e.Item.FindControl(‘btnDetails’)).CommandName = ‘Hide’; } if( e.CommandName == ‘Hide’ ) { ((DataGrid)e.Item.FindControl(‘Datagrid1’)).Visible = false; ((LinkButton )e.Item.FindControl(‘btnDetails’)).Text = ‘+’; ((LinkButton)e.Item.FindControl(‘btnDetails’)).CommandName = ‘Show’; } } protected SqlDataReader GetEmpDetails(string Employeeid ) { string strConnString = ‘server=localhost;uid=sa;pwd=;database=northwind’; SqlConnection objConn = new SqlConnection(strConnString); string strSQL ; strSQL = ‘SELECT FirstName , LastName ,Title, Address FROM Employees WhERE Employeeid = @Employeeid’; SqlCommand objCmd = new SqlCommand(strSQL, objConn); SqlParameter paramEmployeeid ; paramEmployeeid = new SqlParameter(‘@Employeeid’, SqlDbType.VarChar, 10); paramEmployeeid.Value = Employeeid; objCmd.Parameters.Add(paramEmployeeid); objConn.Open() ;// Open the connection; return objCmd.ExecuteReader(CommandBehavior.CloseConnection); }
How to add a Templatecolumn dynamically to a DataList
<asp:DataList id=’DataList1′ runat=’server’></asp:DataList> VB.NET In class Public Class DatalistLabelColumn Implements ITemplate Public Sub New() End Sub ’New Public Sub InstantiateIn(ByVal container As Control) Implements System.Web.UI.ITemplate.InstantiateIn Dim label1 As New Label AddHandler label1.DataBinding, AddressOf Me.BindLabelColumn container.Controls.Add(label1) End Sub ’InstantiateIn Public Sub BindLabelColumn(ByVal sender As Object, ByVal e As EventArgs) Dim lbl As Label = CType(sender, Label) Dim container As DataListItem = CType(lbl.NamingContainer, DataListItem) Dim strVals As [String] = Convert.ToString(DataBinder.Eval(CType(container, DataListItem).DataItem, ‘LastName’)) + ‘, ‘ + Convert.ToString(DataBinder.Eval(CType(container, DataListItem).DataItem, ‘FirstName’)) lbl.Text = strVals End Sub ’BindLabelColumn End Class ’DatalistLabelColumn Dim ds As DataSet = ’Fill the dataset DataList1.ItemTemplate = New DatalistLabelColumn DataList1.DataSource = ds DataList1.DataBind() C# In class public class DatalistLabelColumn : ITemplate { public DatalistLabelColumn() { //Add constructor stuff here } public void InstantiateIn(Control container) { Label label1 = new Label(); label1.DataBinding += new EventHandler(this.BindLabelColumn); container.Controls.Add(label1); } public void BindLabelColumn(object sender, EventArgs e) { Label lbl = (Label)sender; DataListItem container = (DataListItem)lbl.NamingContainer ; String strVals =Convert.ToString(DataBinder.Eval(((DataListItem)container).DataItem, ‘LastName’)) + ‘, ‘ + Convert.ToString(DataBinder.Eval(((DataListItem)container).DataItem, ‘FirstName’)) ; lbl.Text = strVals; } } DataSet ds = //Assign appropriate value; DataList1.ItemTemplate = new DatalistLabelColumn(); DataList1.DataSource =ds; DataList1.DataBind();
Is it possible to pass a querystring from an .asp page to aspx page?
Yes you can pass querystring from .asp to ASP.NET page .asp <%response.redirect ‘webform1.aspx?id=11’%> .aspx VB.NET Response.Write (Request(‘id’).ToString ()) C# Response.Write (Request[‘id’].ToString ());
Are there any IE specific performance improvement possible with Table Layout
In IE5 and later, significantly faster Table Rendering is now possible. Here is some information in MSDN : Enhancing Table Presentation. Among other things, you can specific col specific widths using the colgroup tag or col tag and also set the visibility of rows and columns using special styles.
Are there any resources regarding the Mozilla specific Browser Objects and CSS information
Official Gecko DOM Reference: Gecko Dom Reference Here is a very useful list of custom CSS styles specific to Mozilla: XUL Planet