Click here to Skip to main content
15,890,438 members

Comments by SHIVA1434 (Top 5 by date)

SHIVA1434 23-Mar-16 7:09am View    
Thanks for reply,
No Hajnal....Here is my JSON DATA

[{"Stateid":1,"VAT":0,"CST":0},
{"Stateid":2,"VAT":"1.5","CST":"1.5"},
{"Stateid":3,"VAT":0,"CST":0},{"Stateid":4,"VAT":0,"CST":0},{"Stateid":5,"VAT":0,"CST":0},{"Stateid":6,"VAT":0,"CST":0},{"Stateid":7,"VAT":0,"CST":0},{"Stateid":8,"VAT":0,"CST":0},{"Stateid":9,"VAT":0,"CST":0},{"Stateid":10,"VAT":0,"CST":0},{"Stateid":11,"VAT":0,"CST":0},{"Stateid":12,"VAT":0,"CST":0},{"Stateid":13,"VAT":0,"CST":0},{"Stateid":14,"VAT":0,"CST":0},
SHIVA1434 27-Oct-15 7:04am View    
I want to save datetime in my DB , I got an error like ..
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM

But I gave 27/10/2015 date
..If I give 10/27/2015 ..Then their is no problem
SHIVA1434 27-Aug-15 21:45pm View    
SqlConnection con = new SqlConnection("Data Source=jkjkj-PC;Initial Catalog=employee;Integrated Security=True;user id=sa;password=sa123");
SqlCommand cmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();
DataSet ds = new DataSet();

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ViewState["Filter"] = "Emp";
BindGrid();
}

}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
BindGrid();

}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{

}

protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
BindGrid();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int userid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());
GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
String strConnString = System.Configuration.ConfigurationManager
.ConnectionStrings["conn"].ConnectionString;
SqlConnection con = new SqlConnection(strConnString);

//Label lblID = (Label)row.FindControl("lblID");
//TextBox txtname=(TextBox)gr.cell[].control[];
TextBox textName = (TextBox)row.Cells[0].Controls[0];
TextBox textadd = (TextBox)row.Cells[1].Controls[0];
TextBox textc = (TextBox)row.Cells[2].Controls[0];
//TextBox textadd = (TextBox)row.FindControl("txtadd");
//TextBox textc = (TextBox)row.FindControl("txtc");
GridView1.EditIndex = -1;
con.Open();
//SqlCommand cmd = new SqlCommand("SELECT * FROM detail", conn);
SqlCommand cmd = new SqlCommand("update " + ViewState["Filter"].ToString() + " set name='" + textName.Text + "',address='" + textadd.Text + "',country='" + textc.Text + "'where id='" + userid + "'", con);
cmd.ExecuteNonQuery();
con.Close();
BindGrid();
//GridView1.DataBind();
}
private void BindGrid()
{
DataTable dt = new DataTable();
String strConnString = System.Configuration.ConfigurationManager
.ConnectionStrings["conn"].ConnectionString;
SqlConnection con = new SqlConnection(strConnString);
SqlDataAdapter sda = new SqlDataAdapter();
SqlCommand cmd = new SqlCommand("select * from " + ViewState["Filter"].ToString() + "");
// cmd.CommandType = CommandType.StoredProcedure;
// cmd.Parameters.AddWithValue("@Filter", ViewState["Filter"].ToString());
cmd.Connection = con;
sda.SelectCommand = cmd;
sda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
//DropDownList ddlCountry =
//(DropDownList)GridView1.HeaderRow.FindControl("DropDownList1");
//this.BindCountryList(ddlCountry);
}
//private void BindCountryList(DropDownList ddlCountry)
//{
// String strConnString = System.Configuration.ConfigurationManager
// .ConnectionStrings["conn"].ConnectionString;
// SqlConnection con = new SqlConnection(strConnString);
// SqlDataAdapter sda = new SqlDataAdapter();
// SqlCommand cmd = new SqlCommand("select * from tables");
// cmd.Connection = con;
// con.Open();
// ddlCountry.DataSource = cmd.ExecuteReader();
// ddlCountry.DataTextField = "tablename";
// ddlCountry.Data
SHIVA1434 27-Aug-15 21:40pm View    
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="True"
AllowPaging="true" PageSize="10" Font-Names="Arial"
Font-Size="11pt" AlternatingRowStyle-BackColor="#C2D69B" DataKeyNames="id"
OnRowCancelingEdit="GridView1_RowCancelingEdit"
OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating">
<columns>
<asp:CommandField ShowEditButton="true" />
<asp:CommandField ShowDeleteButton="true" />

<asp:TemplateField>

<HeaderTemplate>
Country:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="CountryChanged">
<%--<asp:ListItem Text="-- Select --" Value="">--%>
<asp:ListItem Text="Emp" Value="Emp">
<asp:ListItem Text="Dept" Value="Dept">
<asp:ListItem Text="AAA" Value="AAA">


</HeaderTemplate>
<%--<itemtemplate>
<%# Eval("Country")%>
--%>







</div>
</form>
</body>
SHIVA1434 27-Dec-14 0:56am View    
Thank you Tadit Dash