using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace IT_2
{
public partial class Date : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
AllTAbleTableAdapters.DateTableAdapter empTA = new AllTAbleTableAdapters.DateTableAdapter();
GridView2.DataSource = empTA.GetDate();
GridView2.DataBind();
}
protected void Edit_Click(object sender, GridViewEditEventArgs e)
{
GridView2.EditIndex = e.NewEditIndex;
GridView2.DataBind();
}
public void Update_Click(object sender, GridViewUpdateEventArgs e)
{
//AllTAbleTableAdapters.DateTableAdapter empTA = new AllTAbleTableAdapters.DateTableAdapter();
//DataTable dt = (DataTable)Session["Date"];
//GridViewRow row = GridView2.Rows[e.RowIndex];
//dt.Rows[row.DataItemIndex]["txtID_Date"] = ((TextBox)(row.Cells[1].Controls[0])).Text;
//dt.Rows[row.DataItemIndex]["txtActual_Date"] = ((TextBox)(row.Cells[2].Controls[0])).Text;
//dt.Rows[row.DataItemIndex]["txtPlan_Date"] = ((TextBox)(row.Cells[3].Controls[0])).Text;
TextBox txtID = (TextBox)GridView2.Rows[e.RowIndex].FindControl("txtID_Date");
TextBox txtAct = (TextBox)GridView2.Rows[e.RowIndex].FindControl("txtActual_Date");
TextBox txtPlan = (TextBox)GridView2.Rows[e.RowIndex].FindControl("txtPlan_Date");
AllTAbleTableAdapters.DateTableAdapter empTA = new AllTAbleTableAdapters.DateTableAdapter();
GridView2.DataSource = empTA.UpdateDate(Convert.ToInt64(txtID.Text), txtAct.Text, txtPlan.Text, Convert.ToInt64(Convert.ToInt64(txtID.Text)));
//empTA.Connection = conn;
//empTA.Update( txtID.Text, txtAct.Text,GridView2.DataKeys[e.RowIndex].Values[0].ToString());
//cmd.Connection = conn;
// empTA.CommandText = "UPDATE Date.dbo SET ID_Date ='" + txtID.Text + "',Actual_Date ='" + txtAct.Text + "',Plan_Date ='" + txtPlan.Text + "' WHERE ID_Date='" + GridView2.DataKeys[e.RowIndex].Values[0].ToString() + "'";
GridView2.EditIndex = -1;
GridView2.DataBind();
}
protected void Create_Click (object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("AddNew"))
{
AllTAbleTableAdapters.DateTableAdapter empTA = new AllTAbleTableAdapters.DateTableAdapter();
TextBox txtID=(TextBox)GridView2.FooterRow.FindControl("txtNewID_Date");
TextBox txtAct = (TextBox)GridView2.FooterRow.FindControl("txtNewActual_Date");
TextBox txtPlan = (TextBox)GridView2.FooterRow.FindControl("txtNewPlan_Date");
GridView2.DataSource = empTA.Insert(Convert.ToInt64(txtID.Text), txtAct.Text, txtPlan.Text);
GridView2.DataBind();
}
}
Проблема с GridView
Написал вроде куда надо=)
Вот код:
Код:
Трабл здесь:
Код:
GridView2.DataSource = empTA.Insert(Convert.ToInt64(txtID.Text), txtAct.Text, txtPlan.Text);
GridView2.DataBind();
GridView2.DataBind();
Просит чтобы я вводил значения (long,strin,string,long), не знаю как это сделать
Помогите разобраться с update,insert,delete,edit в GridView!!!