Tuesday, September 27, 2011

some textbox properties

 <asp:TextBox ID="txtSourceName"  runat="server" AutoCompleteType="Disabled"  TabIndex="1" MaxLength="50" onFocus="this.select()" ></asp:TextBox>


AutoCompleteType="Disabled" ---> this is used to remove the history of the textbox in browser

onFocus="this.select()"  ---> this is used to select the entire text in textbox



Tuesday, September 20, 2011

to show the decimal format of a value in gridview

we have to add like this while binding the data...                                                                                    <asp:Label ID="lbl_PackageRate" runat="server" Text='<%#Eval("Rate","{0:0.00}") %>'></asp:Label>

to show the space in between the values of gridview

 protected void gvRack_RowDataBound(object sender, GridViewRowEventArgs e)
    {
                   if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Label lblStatus = e.Row.FindControl("lblStatus") as Label;
                Label lblRackNo = e.Row.FindControl("lblRackNo") as Label;
                Label lblRackName = e.Row.FindControl("lblRackName") as Label;
                lblRackNo.Text = lblRackNo.Text.Replace(" ", "&nbsp;"); //for showing the spaces in between the words

To show the spaces in between values of dropdown

    protected void ddlRack_DataBound(object sender, EventArgs e)
    {
        ddlRack.Items.Cast<ListItem>().ToList().ForEach(a => a.Text = a.Text.Replace(" ", HttpUtility.HtmlDecode("&nbsp;"))); 
    }