Sunday, February 19, 2012

Assign the null value into the DataRow

this code is shown for assigning null values into the
Datarow...


DataRow[] rows = dataTable1.Select("EqID = " + Convert.ToInt32(txtEquip.Attributes["EquipId"]));
rows[0]["Ph_number"] = string.IsNullOrWhiteSpace(
txtPhNumber.Text) ? DBNull.Value : (object)Convert.ToInt32(txtPhNumber.Text);

Saturday, February 18, 2012

Target control with in the update panel


Move the
ModalPopupExtender to the first update panel:

<asp:ImageButton ID="imgSearch" runat="server" Width="15px" ImageUrl="~/images/search.png"
                            AlternateText="Select Area" OnClientClick="
FileUploadPopup()" />                     
                     

    <ajax:ModalPopupExtender ID="mpopArea1" runat="server" OkControlID="imgClose"
        PopupControlID="
pnlPopUpsearch" BackgroundCssClass="modalBackground" TargetControlID="imgSearch">
    </ajax:ModalPopupExtender>
Panel out side of the update panel
    <asp:Panel ID="pnlPopUpsearch" runat="server">
      <asp:Label ID="lblTest" runat="server" Text="Welcome">
      </asp:Label>
 </asp:Panel>

ValidatorCalloutExtender in asp.net

 <asp:DropDownList runat="server" ID="ddlEquipment" AppendDataBoundItems="true"
                        class="class1">
                        <asp:ListItem Value="-1">--Select Equipment--</asp:ListItem>
                    </asp:DropDownList>
                    <asp:RequiredFieldValidator ID="rfv_
Equipment" runat="server" ControlToValidate="ddlEquipment"
                        InitialValue="-1" ErrorMessage="Please Select Equipment" Display="None"
                        ValidationGroup="Request">
                    </asp:RequiredFieldValidator>
                    <ajax:ValidatorCalloutExtender ID="ValidatorCalloutExtender5" runat="server" PopupPosition="BottomLeft"
                        TargetControlID="rfv_Equipment" Width="180px" WarningIconImageUrl="~/images/icon_blue.png"
                        CssClass="CustomValidatorCalloutStyle">

AsyncPostBackTrigger in UpdatePanel

Could not find an event named 'OnSelectedIndexChanged' on associated control 'dropdownlist1' for the trigger in UpdatePanel 'UpdatePanel1'...
Use selectedindexchanged in the place of OnSelectedIndexChanged for eventname of AsyncPostBackTrigger...
 <asp:UpdatePanel ID="upnlRestrictedArea" runat="server">
         <ContentTemplate>         
            <asp:Panel ID="pnlResArea" runat="server" Style="display: none" BackColor="#F9F6F4"
        Height="350px" Width="380px">
        <div class="PopUpheader">
            <span id="Span1" class="msg">Select Restricted Area</span> <span style="float: right">
                <asp:ImageButton ID="imgClose_resArea" AlternateText="Close" runat="server" ImageUrl="~/images/favicon.ico" /></span>
        </div>
        <table width="85%" class="cssform">
            <tr>
                <td>
                    Select Area :
                </td>
                <td>
                    <asp:DropDownList ID="
ddlRestricted" runat="server" AutoPostBack="true" AppendDataBoundItems="true"
                        OnSelectedIndexChanged="ddlResArea_SelectedIndexChanged">
                        <asp:ListItem Text="--Select Area--" Value="0"></asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
        </table>
        <br />       
    </asp:Panel>
         </ContentTemplate>
         <Triggers>
           <asp:AsyncPostBackTrigger ControlID="ddl
Restricted" EventName="selectedindexchanged" />
         </Triggers>
     </asp:UpdatePanel>

Thursday, February 16, 2012

Get the values from devexpress Gridview in asp.net

protected void grvUserDetails_RowCommand(object sender, ASPxGridViewRowCommandEventArg
s e)
    {
        if (e.CommandArgs.CommandName == "Remove")
        {
            int noOfSelectedRequests =
grvUserDetails.FocusedRowIndex;
            int id = Convert.ToInt32(e.CommandArgs.
CommandArgument.ToString());
            var varSitename =
grvUserDetails.GetRowValues(e.VisibleIndex, "FirstName");
            var objValres =
grvUserDetailsGetRowValues(e.VisibleIndex, "AreaId");
            var objVal1 =
grvUserDetails.GetRowValues(e.VisibleIndex, "Id");
          

        }
    }

Row Index with in the Data Table in asp.net

 foreach (DataRow drow in dtbl.Rows)
        {
            int irow = dtbl.Rows.IndexOf(drow);
            DevExpress.Web.ASPxEditors.
ASPxCheckBox chkIsolated = (DevExpress.Web.ASPxEditors.
ASPxCheckBox)Aspxgrid2.FindRowCellTemplateControl(irow, null, "chkIso");
            if (chkIsolated.Checked == true)
            {
                drow["isIsolate"] = true;
            }    
}



In the above Example also described about Checkbox list of devexpress with in the devexpress gridview in asp.net

Checkboxlist Checked Event Client Side Using JavaScript

<script type="text/javascript"> 
function CheckBoxChecked(ChkID) {
            var status = false;
            var CheckBoxID = document.getElementById('<%=
chkHvecYes.ClientID%>');
            if (CheckBoxID.checked == true){
            status=true;
                return status;}
            else {
                alert('Please Select CheckBox');
                return status;
            }

        }
//chkHvecYes  is checkboxlist Id
function SeletedTab() {         
            var checkBoxArray = document.getElementById('<%=chkIso_action.ClientID%>').getElementsByTagName('input');          
                var checkBoxRef = checkBoxArray[5];     // for 7th Item in the checkboxlist
                if (checkBoxRef.checked) {
document.getElementById('plock').style.display = "block";
 document.getElementById('plock').style.visibility = "visible";
                }

else
                    document.getElementById('plock').style.
display
= "none";document.getElementById('plock').style.visibility = "hidden";
           
        }
</script>
<p id="plock">
  Checkboxlist Checked Event or Onclick Client Side Using JavaScript
</p>
<asp:CheckBoxList  ID="chkIso_action" runat="server" onclick="SeletedTab() ">
<asp:ListItem Text="Test1" Value="0">
<asp:ListItem Text="Test1" Value="1">
<asp:ListItem Text="Test1" Value="2">
<asp:ListItem Text="Test1" Value="3">
<asp:ListItem Text="Test1" Value="4">
<asp:ListItem Text="Test1" Value="5">   
</asp:CheckBoxList >

<asp:Button runat="server" Text="Submit" ID="btnHSubmit" OnClientClick="
CheckBoxChecked(this)"></asp:Button>

Sunday, February 12, 2012

OutPut Cache in asp.net

Setting OutPut Cache in asp.net

<%@ OutputCache Duration="20"  VaryByParam="none" %>  //Created in Web User Control

Char[] Array in asp.net

 char[] arrayInString = "for testing characters";
 int icnt = arrayInString.Length;
   //getting Character array length

Friday, February 10, 2012

Generate Controls Dynamically and adding to the page in asp.net

Getting data from database and generate controls based on table(database) columns and rows, generate label and textbox controls with in a html table dynamically and added to the Page in asp.net.....

private void getallowance()
    {
        DataTable dt = BLayer.getAllowColumns();
        if (dt.Rows.Count > 0)
        {
            //HtmlTableRow htr = new HtmlTableRow();

            Table tbl = new Table();
            tbl.ID = "table1";
            Page.Form.Controls.Add(tbl);
            foreach (DataRow dr in dt.Rows)
            {
                Label lbl = new Label();
                HtmlTableRow htr = new HtmlTableRow();
                HtmlTableCell htc = new HtmlTableCell();
                //htc.ColSpan = 2;
                for (int irow = 0; irow < 6; irow++)
                {
                    htc = new HtmlTableCell();

                 

                    string strcolname = dr["columnname"].ToString();
                    string[] strtestcol = strcolname.Split("_".ToCharArray());
          
                   
                    if (strtestcol.Length <= 1)
                    {
                        if (strcolname.ToUpper() == "CUG" || strcolname.ToUpper() == "TDS" || strcolname.ToUpper() == "LOAN")
                        {
                            if (irow == 4)
                            {
                                lbl.ID = "lbl" + strcolname;
                                lbl.Text = dr["Heading"].ToString();
                                htc.Controls.Add(lbl);
                                htc.Width = "265";
                            }
                            if (irow == 5)
                            {
                                TextBox TextBox1 = new TextBox();
                                TextBox1.ID = "txt" + strcolname;
                                TextBox1.CssClass = "formstyle01";
                                TextBox1.Enabled = false;
                                TextBox1.Font.Bold = true;
                                TextBox1.Text = string.Empty;
                                TextBox1.Style.Add("text-align", "right");
                                htc.Controls.Add(TextBox1);
                                htc.Width = "150";
                            }

                            htr.Cells.Add(htc);
                            tblcolded.Rows.Add(htr);
                        }
                    }
                    else
                    {
                        //htr = new HtmlTableRow();
                        if (irow == 2)
                        {
                            htc.Style["bgcolor"] = "#807d7d";
                            //htc.Controls.Add(cell);
                        }
                        if (irow == 3)
                        {
                         
                            //row.Style["bgcolor"] = "#807d7d";
                            //htc.Controls.Add(row);
                        }
                        if (strtestcol[1].ToString() == "a")
                        {
                            if (irow == 0)
                            {
                                lbl.ID = "lbl" + strcolname;
                                lbl.Text = dr["Heading"].ToString();
                                htc.Controls.Add(lbl);
                                htc.Width = "265";
                            }
                            if (irow == 1)
                            {
                                TextBox TextBox1 = new TextBox();
                                TextBox1.ID = "txt" + strcolname;
                                TextBox1.CssClass = "formstyle01";
                                TextBox1.Enabled = false;
                                TextBox1.Font.Bold = true;
                                TextBox1.Text = string.Empty;
                                TextBox1.Style.Add("text-align", "right");
                                htc.Controls.Add(TextBox1);
                                //htr.Cells.Add(htc);
                                htc.Width = "150";
                                htc.VAlign = "middle";
                                htc.Align = "left";                              
                            }
                            htr.Cells.Add(htc);
                            htr.VAlign = "top";
                            tblcol.Rows.Add(htr);
                          
                        }
                        else if (strtestcol[1].ToString() == "d")
                        {
                            if (irow == 4)
                            {
                                //Label lbl = new Label();
                                lbl.ID = "lbl" + strcolname;
                                lbl.Text = dr["Heading"].ToString();
                                htc.Controls.Add(lbl);
                                htc.Width = "265";
                            }
                            if (irow == 5)
                            {
                                TextBox TextBox1 = new TextBox();
                                TextBox1.ID = "txt" + strcolname;
                                TextBox1.CssClass = "formstyle01";
                                TextBox1.Enabled = false;
                                TextBox1.Font.Bold = true;

                                TextBox1.Style.Add("text-align", "right");
                                TextBox1.Text = string.Empty;
                                htc.Controls.Add(TextBox1);
                                //htr.Cells.Add(htc);
                                htc.Width = "150";
                                //tblcol.Rows.Add(htr);
                            }

                            htr.Cells.Add(htc);
                            //tblcol.Rows.Add(htr);
                            tblcolded.Rows.Add(htr);
                        }
                    }              
                 
                }              

            }
          
        }
      
    }
Protected by Copyscape Plagiarism Software