Wednesday, 15 December 2010

How to work with fieldset and legend html tags?

 This is the sample for working with <fieldset> and <legend> html tags.


<fieldset style="text-align: left; width: 49%;"align="left">      <legend style="text-align: left; font-weight: 700;">
<img style="width: 50px; border-width: 0px;" src="../Images/interview_icon.jpg" id="ctl00_CPH_Image2">
&nbsp;
<span style="display: inline-block; color: White; background-color: Blue; border-color: White; border-style: double; font-size: 10pt;" class="Label_name" id="ctl00_CPH_Label334">Action</span>
&nbsp;&nbsp;&nbsp; 
</legend>
<table align="center">
<tbody>
<tr>
<td style="text-align: right;" class="style2">&nbsp;</td>
<td style="text-align: left;" class="style4">&nbsp;</td>
<td style="text-align: left;">&nbsp;</td>
</tr>
<tr> 
<td style="text-align: right;" class="style2">
<span class="Label_name" id="ctl00_CPH_Label332">Hiring Process  :</span>
</td>
<td style="text-align: left;" class="style4">
<select style="width: 250px;" id="ctl00_CPH_DDL_Hiring" onchange="javascript:setTimeout('__doPostBack(\'ctl00$CPH$DDL_Hiring\',\'\')', 0)" name="ctl00$CPH$DDL_Hiring">
            <option value="0">Select</option>
            <option value="1">Hiring Key</option>
            <option value="2">Line Partner Key</option>
            <option value="3">Line Payroll Key</option>
        </select>
</td>
<td style="text-align: left;">
<input type="submit" style="color: Blue;" class="Button_Normal" id="ctl00_CPH_btnProcess" value="Process" name="ctl00$CPH$btnProcess">
</td>
</tr>
</tbody></table>
</fieldset>

What is the difference between <%# Eval("Name") %> and <%# DataBinder.Eval(Container.DataItem,"Name") %>

What is the difference between <%# Eval("Name") %> and <%# DataBinder.Eval(Container.DataItem,"Name") %> in your aspx page?

::: Eval("Name") is a simplified form of the DataBinder.Eval(Container.DataItem, "Name") syntax.
It only works inside of data-bound template controls.

what is difference between functions and methods?

You can know what is difference between functions and methods from the following link.
http://www.eggheadcafe.com/community/aspnet/2/10046933/what-is-difference-between-functions-and-methods.aspx

What is "View State" ?

This is just detail explanation about the view state element of the asp.net frame work.
http://www.dotnetspider.com/resources/609-ViewState-ASP-NET.aspx

Tuesday, 14 December 2010

Getting data and datakeys inside the Grid View

::: Getting run time control  of the grid view inside the RowDataBound method.
Private Sub  GridView1_RowDataBound(ByVal sender As Object,  
ByVal e As  System.Web.UI.WebControls.GridViewRowEventArgs) 
Handles  GridView1.RowDataBound

If CType(e.Row.FindControl("LblLanguagesCode"), Label).Text = "" Then
e.Row.Cells(2).Text = ""
End If

End Sub

::: Getting datakeynames of the grid view inside the RowDataBound method.
 Private Sub  Grid_Work_Experience_RowDataBound(ByVal sender As Object,  
ByVal e As  System.Web.UI.WebControls.GridViewRowEventArgs)  
Handles  Grid_Work_Experience.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
   Dim Employer As String = Grid_Work_Experience.DataKeys(e.Row.RowIndex).Values("Employer") & ""
   Dim Position As String = Grid_Work_Experience.DataKeys(e.Row.RowIndex).Values("Position") & ""
   If Employer <> "" Then
     e.Row.Cells(3).Text = Employer
   End If
   If Position <> "" Then
      e.Row.Cells(3).Text = Employer & " / " & Position
   End If
End If
End Sub
::: Finding the control of selected row inside the RowUpdating method

Private Sub  GridView1_RowUpdating(ByVal sender As Object,  
ByVal e As  System.Web.UI.WebControls.GridViewUpdateEventArgs)Handles  GridView1.RowUpdating
Dim Continent_Name As String = CType(Me.GridView1.Rows(e.RowIndex).FindControl("TxtContinentNameEdit"), TextBox).Text
If Continent_Name = "" Then
CType(Me.AlertMessageBox1.FindControl("lblMessage"), Label).Text = "Please input Continent Name field !!!"
Me.Mpe_AlertMessage.Show()
Me.ShowContinentData()
CType(Me.DtgContinent.Rows(e.RowIndex).FindControl("TxtContinentNameEdit"), TextBox).Text = Continent_Name
End If
End Sub

::: Finding the control of gridview inside the normal method
Protected Sub ImgSaveAddNew_Click(ByVal sender As Object,  
ByVal e As System.Web.UI.ImageClickEventArgs)
Dim Languages_Name As String = CType(Me.GridView1.FooterRow.FindControl("TxtLanguagesNameAddNew"), TextBox).Text
End Sub

Skip Validations While Clicking Cancel Button in ASP.net

You just need to add CausesValidation=”False” attribute in the cancel button of aspx page.
To skip all the validations while clicking the cancel button whether the validation status is true or false.

Easy Solution for Error “The page has one or more controls….” in the Design View

Sometimes, the following error could show in the design view of the individual (aspx) page. That means something wrong or not suitable tags in the (Page.Master) file of your project.

The page has one or more <asp:Content> controls that do not correspond with <asp:ContentPlaceHolder> controls in the Master Page.
Whenever you face with this kind of error, please don’t forget to check out the following tips:
  • Remove Comments <%—-%>
  • Instead of <title />, <script />, <input /> replace with like <title><title/>, <script></script>
  • Make sure the ContentPlaceHolderID in
    <asp:Content ID="contentMain" ContentPlaceHolderID="contentPlaceHolderMain" Runat="Server">
    matches id in each individual aspx page
    <asp:ContentPlaceHolder id="contentPlaceHolderMain" runat="server" />
Problem are solved when I got above problem.

Changing Column HeaderText of GridView Dynamically in the RunTime (C#)

I hope the following codes could help you. In the side of sample.aspx file:

<asp:GridView ID="GridView1" runat="server"  OnRowCreated = "GridView1_RowCreated"> </asp:GridView>

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cell[1].Text = "id";
e.Row.Cells[2].Text = "Employee ID";
//You can skip if you made visible="false" for the cell number 3.
e.Row.Cells[4].Text = "KPI Description";
}
}
In the other way, you can try applying looping in this function called GridView1_RowCreated.

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
for (int i = 0; i < e.Row.Cells.Count;i++)
{
if (e.Row.Cells[i].Text == “CORP”)
e.Row.Cells[i].Text = “WinCorp”;
if (e.Row.Cells[i].Text == “PTNR”)
e.Row.Cells[i].Text = “WinPtnr”;
if (e.Row.Cells[i].Text == “SCORP”)
e.Row.Cells[i].Text = “WinScorp”;
if (e.Row.Cells[i].Text == “FIDUC”)
e.Row.Cells[i].Text = “WinFiduc”;
if (e.Row.Cells[i].Text == “WINTAX”)
e.Row.Cells[i].Text = “WinTax”;
if (e.Row.Cells[i].Text == “WINPAY”)
e.Row.Cells[i].Text = “WinPay”;
if (e.Row.Cells[i].Text == “DEPR”)
e.Row.Cells[i].Text = “WinDepr”;
if (e.Row.Cells[i].Text == “CORP”)
e.Row.Cells[i].Text = “WinCorp”;
}
}
 
Reference: http://www.pederborg.dk/2007/01/25/changing-gridview-column-headertext-at-runtime/

Adding Drop Downl List & Textbox Pager Style inside the GridView of ASP.net (C#)

In the Grid View of aspx page, you should add the following codes:

<asp:GridView ID="GridView_AA" runat="server" 
DataKeyNames="ID,PERIOD_NAME,status" AllowPaging = "true" 
ondatabound="GridView_AA_DataBound" PageSize = "5" >
<%--Pager--%>
<PagerStyle forecolor="Blue" backcolor="LightBlue"/><PagerTemplate>
<table>
<tr>
<td style="width:150px">
<asp:label id="MessageLabel"
forecolor="white"
text="Select a page:"
runat="server"/>
<asp:dropdownlist id="PageDropDownList"
autopostback="true"
onselectedindexchanged="PageDropDownList_SelectedIndexChanged"
runat="server" Width="36px" />
</td>
<td style="width:540px; text-align:center;">
<asp:label id="CurrentPageLabel" forecolor="white" runat="server"/>
</td>
<%--Go Command--%>
<td style="width:200px; height:26px; text-align:right; float:right;">
Page : <asp:TextBox id="txtGo" runat="server" Width="30px" />
<asp:RangeValidator ID="rvtxtGo" runat="server"
ControlToValidate= "txtGo" Type="Integer"
MaximumValue="100" MinimumValue="1" ></asp:RangeValidator>
<asp:Button id="btnGo" Text="Go" runat="server" 
OnClick="btnGo_Click" Width="30px" />
</td>
<%--Go Command--%>
</tr>
</table>
</PagerTemplate>
<%--Pager--%>
</asp:GridView>
protected void GridView_AA_DataBound(Object sender, EventArgs e)
{
GridViewRow pagerRow = GridView_AA.BottomPagerRow;
DropDownList pageList = (DropDownList)pagerRow.Cells[0].FindControl("PageDropDownList");
Label pageLabel = (Label)pagerRow.Cells[0].FindControl("CurrentPageLabel");
if (pageList != null)
{
for (int i = 0; i < GridView_AA.PageCount; i++)
{
int pageNumber = i + 1;
ListItem item = new ListItem(pageNumber.ToString());
if (i == GridView_AA.PageIndex)
{
item.Selected = true;
}
pageList.Items.Add(item);
}
}
if (pageLabel != null)
{
int currentPage = GridView_AA.PageIndex + 1;
pageLabel.Text = "░ Page " + currentPage.ToString() +
" of " + GridView_AA.PageCount.ToString() + " ░";
}
}
protected void PageDropDownList_SelectedIndexChanged(Object sender, EventArgs e)
{
GridViewRow pagerRow = GridView_AA.BottomPagerRow;
DropDownList pageList = (DropDownList)pagerRow.Cells[0].FindControl("PageDropDownList");
try
{
SqlConnection sqlConn = new SqlConnection(connStr);
string sql = "SELECT * FROM ANNUAL_ASSESSMENT";
sqlConn.Open();
SqlDataAdapter da = new SqlDataAdapter();
da = new SqlDataAdapter(sql, sqlConn);
DataSet ds = new DataSet();
da.Fill(ds, "PAGING_ANNUAL_ASSESSMENT");
foreach (DataRow row in ds.Tables[0].Rows)
{
row[2] = Config.StrYYYYMMDDtoDate(row[2].ToString());
row[3] = Config.StrYYYYMMDDtoDate(row[3].ToString());
}
ds.AcceptChanges();
GridView_AA.DataSource = ds.Tables["PAGING_ANNUAL_ASSESSMENT"];
GridView_AA.PageIndex = Convert.ToInt32(pageList.SelectedValue) - 1;
GridView_AA.DataBind();
sqlConn.Close();
ImageSettingGridview();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
protected void btnGo_Click(object sender, EventArgs e)
{
GridViewRow pagerRow = GridView_AA.BottomPagerRow;
TextBox pageList = (TextBox)pagerRow.Cells[0].FindControl("txtGo");
try
{
SqlConnection sqlConn = new SqlConnection(connStr);
string sql = "SELECT * FROM ANNUAL_ASSESSMENT";
sqlConn.Open();
SqlDataAdapter da = new SqlDataAdapter();
da = new SqlDataAdapter(sql, sqlConn);
DataSet ds = new DataSet();
da.Fill(ds, "PAGING_ANNUAL_ASSESSMENT");
foreach (DataRow row in ds.Tables[0].Rows)
{
row[2] = Config.StrYYYYMMDDtoDate(row[2].ToString());
row[3] = Config.StrYYYYMMDDtoDate(row[3].ToString());
}
ds.AcceptChanges();
GridView_AA.DataSource = ds.Tables["PAGING_ANNUAL_ASSESSMENT"];
GridView_AA.PageIndex = Convert.ToInt32(pageList.Text) - 1;
GridView_AA.DataBind();
sqlConn.Close();
ImageSettingGridview();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}

I hope you can try by yourself according to the above example.

Reference: http://www.aspnettutorials.com/tutorials/controls/gvpagertemplate-csharp.aspx

Quite Samples of “NOT IN” Sql Statement

You want to select field of first table that not contain in the second table. You can write SQL statement like this….

SELECT a FROM x WHERE x.b NOT IN (SELECT b FROM y);
 
Reference: http://stackoverflow.com/questions/232935/sql-query-where-field-does-not-contain-x

Confliction of ‘, ” in the SQL Stored Procedure

CREATE PROCEDURE [dbo].[sprocFilterByFYCode_KPI_PERSONEList]
@filterValue varchar(50)
AS
BEGIN
SELECT
kp.ID,
ks.[DESCRIPTION] AS KPI_CODE,
ann.ID AS FY_CODE,
kp.EMPLOYEE_ID,
kp.[KEY],
kp.PERIOD_START,
kp.PERIOD_END,
kp.DEFAULT_TARGET,
kp.INITIATIVE,
kp.ATTACH_FILE,
kp.LAST_UPDATE,
kp.[STATUS],
kp.APPROVER,
ks.KPI_CODE AS KPI_CODE_ID
FROM
KPI_PERSON as kp
LEFT JOIN
ANNUAL_ASSESSMENT as ann on kp.FY_CODE = CONVERT(int,ann.ID)
LEFT JOIN
KPI_STRUCTURE as ks on kp.KPI_CODE = ks.KPI_CODE
WHERE kp.FY_CODE = @filterValue
END
 
You can pass the specified parameter like showing in the above or on the another way you can also use like the following: WHERE kp.FY_CODE LIKE @filterValue filtering Like keyword.
But, note that you do not require ‘ or double code  kp.FY_CODE = ‘@filterValue‘ or kp.FY_CODE LIKE ‘@filterValue’ like this.
Containing single or double code can’t work probably when you run your project in the browser although you can test  and show correct results/records well in the SQL Management Studio.
 

How do you get small logo in the address bar?

I don't think that IE Explorer supports it. 
But if you have firefox or Chrome, you should see a small W logo in the address bar of WordPress. 
<HEAD> <TITLE>My Project</TITLE> <link rel="icon" href="/images/logo.png" type="image/png"> </HEAD>

Sorting of GridView Control and Changing HeaderText Dynamically (C#)

The following code is my Grid View_AA from aspx page.

<asp:TemplateField HeaderText="Period Name" SortExpression="PERIOD_NAME">
<EditItemTemplate>
<asp:TextBox ID="txtGVPeriodName" runat="server" 
Text='<%# Bind("PERIOD_NAME") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblGVPeriodName" runat="server" 
Text='<%# Bind("PERIOD_NAME") %>' Visible="False">
</asp:Label>
<asp:LinkButton ID="lborganize" runat="server" 
OnClick="lborganize_Click" Text='<%# Bind("PERIOD_NAME") %>'>
</asp:LinkButton>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" Width="400px" />
<ItemStyle HorizontalAlign="Center" Width="400px" />
</asp:TemplateField>
</asp:GridView>

protected void GridView_AA_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
LinkButton lb_pname = (LinkButton)(e.Row.Cells[2].Controls[0]);
lb_pname.Text = "Period Nameāļ°";
e.Row.Cells[2].Controls.Add(lb_pname);
}
}
 
The above code is working well in my project. I hope you can get some references from it. Have a nice day!

Changing default startup page Asp.net

You should put the following code in web.config file:

<configuration>
<system.webServer>
<defaultDocument>
<files>
<add value="index.ashx" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
Please write code to redirect your required page in the page load of  (index.aspx) file. Note that you have to choose correct path of your  start up page if your start up page is located in sub folder of your  project.

protected void Page_Load(object sender, EventArgs e)
{
Response.Redirect("FormBusiness/KPIPerson.aspx");
}
After doing in the above, you can get your project’s start up page as KPIPerson.aspx.

Reference: http://stackoverflow.com/questions/1022949/change-default-startup-page-asp-net-windows-hosted-godaddy

Free Online Dictionary Merriam-Webster

  • When you search a word, you will see not only the meaning of the words but also Examples of INVOKE, Origin of INVOKE, Related to INVOKE(Synonyms), Rhymes with INVOKE. 
  • If your English skill is beginner, you can also learn from the link "See invoke defined for English-language learners » " 
  • This link will also allow you to listen the pronunciation of your searched word. 

Free English to Myanmar, Myanmar to English Dictionary

  • This site applies to search in English and show the results in Myanmar/Burmese. 
  • Also allow to search with Myanmar/Burmese keywords by choosing Myanmar Alphabet from the tables. 
  • We can use this dictionary without requiring any installation.