Translate

Thursday, 5 February 2015

split string assign in gridview

 protected void btnShow_Click(object sender, EventArgs e)
    {
        string value = "Pabitra,Pabitra2,Pabitra3,Pabitra4,Pabitra5";
       // using System.Text.RegularExpressions;
       // string[] lines = Regex.Split(value, ",");
        string[] lines = value.Split(',');
        DataTable dt = new DataTable();
        dt.Columns.Add("Name");
        foreach (string line in lines)
        {
            DataRow dr = dt.NewRow();
            dr["Name"] = line;
            dt.Rows.Add(dr);
        }
        GridView1.DataSource = dt;
        GridView1.DataBind();
    }

Monday, 2 February 2015

how to find control in gridview rowcommand in asp.net c# ?

 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("Find"))
        {
           One Way(1)
          ----------
                     // int indexno = int.Parse(e.CommandArgument.ToString());
                     // GridViewRow row = GridView1.Rows[indexno ];
          One Way(2)
          ----------
            GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);                 Label SubCatID = (Label)row.FindControl("lblSubCatID");
            string Sub = SubCatID.Text;      
       
        }
    }    

Procedure Error Handleing

create proc MyProcedure
(
@Emp_Id int,
@Name nvarchar(50),
@Action varchar(3),
@message nvarchar(100) output
)
as
begin
 if(@Action='U')
 begin
  update tblEMP set E_name=@Name where Emp_Id=@Emp_Id  
 end    
 if(@@ERROR=0)
  set @message='Save successfully.'
 else
  set @message='Error in deletion.'
end  

Dialog box in C$ web app

using System.Windows.Forms;
--------------------------------------------
 int x=Insert(txtId.Text,txtName.Text);

if (MessageBox.Show(msg+"  Do you want Add another In The same species .. ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                   
                }else

{

}

Saturday, 31 January 2015

Alert Msg In C#

  string msg = InsertEmployee(1,txtName.Text);

 ScriptManager.RegisterStartupScript(this,this.GetType(),"", "alert('" + msg + "');window.location.href=('Default.aspx');", true);




ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:alert('Please Enter Data')", true);



----------------------
 Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('Insufficient Access Previlage');window.location.href=('LogiPage.aspx');", true);

ClientScript.RegisterStartupScript(GetType(), "alert", "alert('" + msg + "');window.location.href='InsertPage.aspx';", true);
------------------------

 ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('" + msg + "');", true);     
                 //ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('" + msg + "');window.location.href=('Default.aspx');", true);     
                ScriptManager.RegisterStartupScript(this,this.GetType(),"","alert('ddddddddd');", true);  

Saturday, 24 January 2015

Google Map Current Loacatation

Copy the Code And Past in Aspx Page and Run You Find the Current Locatation
------------------------------------------------------------------


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

<!DOCTYPE html>
<html>
    <head>
        <script src="http://maps.google.com/maps/api/js?sensor=false">
        </script>
        <script>
            if (navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(showCurrentLocation);
            }
            else {
                alert("Geolocation API not supported.");
            }

            function showCurrentLocation(position) {
                var latitude = position.coords.latitude;
                var longitude = position.coords.longitude;
                var coords = new google.maps.LatLng(latitude, longitude);

                var mapOptions = {
                    zoom: 15,
                    center: coords,
                    mapTypeControl: true,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };

                //create the map, and place it in the HTML map div
                map = new google.maps.Map(
                document.getElementById("mapPlaceholder"), mapOptions
                );

                //place the initial marker
                var marker = new google.maps.Marker({
                    position: coords,
                    map: map,
                    title: "Current location!"
                });
            }
        </script>
    </head>
    <style>
    #mapPlaceholder {
        height: 400px;
        width: 700px;
    </style>
    <body>
        <div>
        <h2>HTML5 Show Location on GoogleMap Sample</h2>
        <div id="mapPlaceholder"></div>
        </div>
    </body>
</html>

Wednesday, 21 January 2015

Split Sting

  string SplitString = "Hello Pabitra !123456! City IS :bhubaneswar";
        string Name = SplitString.Split('!')[1];
        string City = SplitString.Split(':')[1];
         Response.Write(Name);
         Response.Write(City);