本文整理汇总了C#中GridViewUpdateEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# GridViewUpdateEventArgs类的具体用法?C# GridViewUpdateEventArgs怎么用?C# GridViewUpdateEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GridViewUpdateEventArgs类属于命名空间,在下文中一共展示了GridViewUpdateEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GridView1_RowUpdating
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string sno = (GridView1.Rows[e.RowIndex].Cells[3].Controls[0] as TextBox).Text;
string sname = (GridView1.Rows[e.RowIndex].Cells[4].Controls[0] as TextBox).Text;
string ssex = (GridView1.Rows[e.RowIndex].Cells[5].Controls[0] as TextBox).Text;
string sage = (GridView1.Rows[e.RowIndex].Cells[6].Controls[0] as TextBox).Text;
string sdept = (GridView1.Rows[e.RowIndex].Cells[7].Controls[0] as TextBox).Text;
using (
SqlConnection connection =
new SqlConnection(connectionString))
{
string commanText =
string.Format("UPDATE Student SET Sname = '{0}', Ssex = '{1}', Sage = '{2}', Sdept = '{3}' WHERE Sno = '{4}'", sname,
ssex, sage, sdept, sno);
var command = new SqlCommand(commanText, connection);
if (connection.State != ConnectionState.Open)
{
connection.Open();
}
command.ExecuteNonQuery();
GridView1.EditIndex = -1;
BindGridView();
}
}
示例2: GridView1_RowUpdating
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
var List = new List<Student_Registration_Form>();
var db = new DataClassesDataContext();
string _accountType, _email, _contactMethod, _campus, _faculty, _course;
int _phone, _mobile;
_accountType = ((TextBox) (GridView1.Rows[e.RowIndex].FindControl("textAccType"))).Text;
_email = ((TextBox) (GridView1.Rows[e.RowIndex].FindControl("textEmail"))).Text;
//_citizenship = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("Marital_Status"))).Text;
_contactMethod = ((TextBox) (GridView1.Rows[e.RowIndex].FindControl("textContact"))).Text;
_campus = ((TextBox) (GridView1.Rows[e.RowIndex].FindControl("textCampus"))).Text;
_faculty = ((TextBox) (GridView1.Rows[e.RowIndex].FindControl("textFaculty"))).Text;
_course = ((TextBox) (GridView1.Rows[e.RowIndex].FindControl("textCourse"))).Text;
//_phone = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl.("textPhone"))).ToString();
//_mobile = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("textMobile"))).Text;
var update = (from u in db.Student_Registration_Forms
where u.Accomodition_Type == _accountType
where u.Email == _email
//where u.Marital_Status == _citizenship
where u.Contact == _contactMethod
where u.campus == _campus
where u.Faculty == _faculty
where u.Courses == _course
select u);
GridView1.DataSource = List;
db.SubmitChanges();
BindGrid();
}
示例3: GridView1_RowUpdating
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int _selectedRowIndex = e.RowIndex;
// HiddenField hidden = (HiddenField)
int projID = (int)GridView1.DataKeys[_selectedRowIndex].Values[2];
int rowIndex = GridView1.SelectedIndex;
// int projID = Convert.ToInt32( GridView1.DataKeys[rowIndex].Values[2]);
// int projID = 4;
TextBox txtForMark = (TextBox)(GridView1.Rows[e.RowIndex].FindControl("theMarkTextBox"));
string newMark = txtForMark.Text.ToString();
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
try
{
// con.Open();
string upDate = "UPDATE StudentsProjects SET mark=" + newMark + " WHERE projectID=" + projID + " ";
// SqlCommand updateCommand = new SqlCommand(upDate, con);
// updateCommand.CommandType = CommandType.Text;
// updateCommand.ExecuteNonQuery();
// con.Close();
// SqlDataSource1.Update();
SqlDataSource1.UpdateCommand = upDate;
// GridView1.DataSource = SqlDataSource1;
// GridView1.DataBind();
}
catch { }
//SqlDataSource1.Update();
}
示例4: gv_weddingCustomer_RowUpdating
protected void gv_weddingCustomer_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = (GridViewRow)gv_weddingCustomer.Rows[e.RowIndex];
Label lblCustomerID = (Label)row.FindControl("lblid");
Label lblSalutation = (Label)row.FindControl("lblid1");
TextBox textFname = (TextBox)row.FindControl("textbox1");
TextBox textLname = (TextBox)row.FindControl("textbox2");
TextBox textstate_Address = (TextBox)row.FindControl("textbox3");
TextBox textCity = (TextBox)row.FindControl("textbox4");
TextBox textPostelCode = (TextBox)row.FindControl("textbox5");
TextBox textPhone = (TextBox)row.FindControl("textbox6");
TextBox textEmail = (TextBox)row.FindControl("textbox7");
TextBox textCountry = (TextBox)row.FindControl("textbox8");
TextBox textPassport_num = (TextBox)row.FindControl("textbox9");
gv_weddingCustomer.EditIndex = -1;
String customerUpdateQuery = "update Customer set fname = '" + textFname.Text + "',lname = '" + textLname.Text + "' where CustomerID = " + lblCustomerID.Text + " ";
bool updateResult = dc.insert(customerUpdateQuery);
lblUpdateMsg.Visible = true;
if (updateResult == true)
{
lblUpdateMsg.Text = "Details of Customer with ID '" + lblCustomerID.Text + "' was sucessly updated!";
}
else
{
lblUpdateMsg.Text = "Sorry!Unable to be update Details of Customer with ID '" + lblCustomerID.Text + "'!";
}
fillGrid();
}
示例5: GrdLoadJobCompany_RowUpdating
protected void GrdLoadJobCompany_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int indexrow = e.RowIndex;
string tid = ((Label)GrdLoadJobCompany.Rows[indexrow].FindControl("PostJobId")).Text;
Response.Redirect("~/ShowJobDetails.aspx?PostJobId=" + tid);
}
示例6: GridView1_RowUpdating
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
TextBox my_MaterialName, my_PurchaseUnit, my_ConsumeUnit, my_ConversionFactor, my_MaterialSafeQuantity, my_MaterialTypeID, my_MaterialUnit, my_Active;
String my_NO = gv.DataKeys[e.RowIndex].Value.ToString();
my_MaterialName = (TextBox)gv.Rows[e.RowIndex].Cells[2].Controls[0];
my_PurchaseUnit = (TextBox)gv.Rows[e.RowIndex].Cells[3].Controls[0];
my_ConsumeUnit = (TextBox)gv.Rows[e.RowIndex].Cells[4].Controls[0];
my_ConversionFactor = (TextBox)gv.Rows[e.RowIndex].Cells[5].Controls[0];
my_MaterialSafeQuantity = (TextBox)gv.Rows[e.RowIndex].Cells[6].Controls[0];
my_MaterialTypeID = (TextBox)gv.Rows[e.RowIndex].Cells[7].Controls[0];
my_MaterialUnit = (TextBox)gv.Rows[e.RowIndex].Cells[8].Controls[0];
my_Active = (TextBox)gv.Rows[e.RowIndex].Cells[9].Controls[0];
//檢查更新是否成功
if (UpdateICS_Material(my_NO, my_MaterialName, my_PurchaseUnit, my_ConsumeUnit, my_ConversionFactor, my_MaterialSafeQuantity, my_MaterialTypeID, my_MaterialUnit, my_Active))
{
ShowMsg2(UpdatePanel1, "更新成功");
}
else
{
ShowMsg2(UpdatePanel1, "更新失敗");
}
gv.EditIndex = -1;
InitData();
SearchData();
}
示例7: GridView1_RowUpdating
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int postid = 0;
string postcontent = "";
DateTime modified = DateTime.Now;
string poststatus = "";
int rating = 0;
postid = Convert.ToInt16(((Label)GridView1.Rows[e.RowIndex].FindControl("lblpostid")).Text);
postcontent = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtPostContent")).Text;
poststatus = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtstatus")).Text;
rating = Convert.ToInt16(((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtrating")).Text);
PostBLL pb = new PostBLL();
int i= pb.UpdatePost(postid,postcontent,modified,poststatus,rating);
if (i == 1)
{
Response.Write("<script language='javascript'>alert('Post has been updated !');</script>");
GridView1.DataBind();
}
else
{
Response.Write("<script language='javascript'>alert('Post is failed to be updated !');</script>");
GridView1.DataBind();
}
}
示例8: GvOrder_RowUpdating
protected void GvOrder_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int i = e.RowIndex;
DataRow rOrder = TableOrder.Rows[i];
GridViewRow row = GvOrder.Rows[e.RowIndex];
double f = -1;
double.TryParse(((TextBox)(row.Cells[1].Controls[0])).Text,out f);
int quant = (int)f;
if (quant < 0) return;
string s = (string)rOrder[4];
if (s[0] > '9' || s[0] <= '0')
{
//get rid of "$"
s = s.Substring(1);
}
rOrder["SubPrice"] = (Convert.ToDouble(s) * quant).ToString("C");
rOrder["Quantity"] = quant;
GvOrder.EditIndex = -1;
Update();
}
示例9: gridViewFarms_RowUpdating
protected void gridViewFarms_RowUpdating(object sender,
GridViewUpdateEventArgs e)
{
GridViewRow row = gridViewFarms.Rows[e.RowIndex];
try
{
sqlConnection.Open();
SqlCommand cmd = sqlConnection.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "UpdateNotes";
cmd.Parameters.Add("@VillageCoordinates", SqlDbType.Int).Value = ((TextBox) row.Cells[0].Controls[0]).Text;
cmd.Parameters.Add("@Notes", SqlDbType.NVarChar).Value = ((TextBox) row.Cells[7].Controls[0]).Text;
cmd.ExecuteNonQuery();
}
catch (SqlException ex)
{
LabelStatus.Text = ex.ToString();
}
finally
{
sqlConnection.Close();
}
gridViewFarms.EditIndex = -1;
PopulateGridView();
}
示例10: GridView1_RowUpdating
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
UserDetails userDetails = new UserDetails();
userDetails.userID = GridView1.Rows[e.RowIndex].Cells[0].Text;
userDetails.firstName = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text;
userDetails.lastName = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text;
userDetails.phone = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[5].Controls[0])).Text;
userDetails.cityID = int.Parse(((DropDownList)(GridView1.Rows[e.RowIndex].Cells[3].FindControl("DropDownList1"))).SelectedValue);
userDetails.address = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[6].FindControl("TextBox1"))).Text;
userDetails.state = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[6].FindControl("TextBox3"))).Text;
userDetails.zipCode = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[6].FindControl("TextBox2"))).Text;
UserService userService = new UserService();
userService.UpdateUserDetails(userDetails);
GridView1.EditIndex = -1;
populateGrid();
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
}
示例11: gridStudent_RowUpdating
protected void gridStudent_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
SqlConnection connection = SqlHelper.GetConnection();
var dataAdapter = new SqlDataAdapter(selectCommandText, connection);
var builder = new SqlCommandBuilder(dataAdapter);
dataAdapter.DeleteCommand = builder.GetDeleteCommand();
DataSet dataSet = SqlHelper.GetDataSetBySqlCommand(selectCommandText, connection);
string studentID = (gridStudent.Rows[e.RowIndex].Cells[1].Controls[0] as TextBox).Text;
string name = (gridStudent.Rows[e.RowIndex].Cells[2].Controls[0] as TextBox).Text;
string gender = (gridStudent.Rows[e.RowIndex].Cells[3].Controls[0] as TextBox).Text;
string dayOfBirth = (gridStudent.Rows[e.RowIndex].Cells[4].Controls[0] as TextBox).Text;
string address = (gridStudent.Rows[e.RowIndex].Cells[5].Controls[0] as TextBox).Text;
string department = (gridStudent.Rows[e.RowIndex].Cells[6].Controls[0] as TextBox).Text;
//获取 DataSet 中与点击了 “编辑” 按钮的这行对应的数据行
DataRow row = dataSet.Tables[0].Rows[e.RowIndex];
//修改其中各字段的值
row["StudentID"] = studentID;
row["Name"] = name;
row["Gender"] = gender;
row["DayOfBirth"] = dayOfBirth;
row["Address"] = address;
row["Department"] = department;
//提交到数据库中
dataAdapter.Update(dataSet);
gridStudent.EditIndex = -1;
ShowData();
}
示例12: GridView1_RowUpdating
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow gvr = this.GridView1.Rows[this.GridView1.EditIndex];
DropDownList ddl = (DropDownList)gvr.Cells[9].FindControl("DropDownList1");
e.NewValues["Type"] = ddl.SelectedValue;
}
示例13: UserAccounts_RowUpdating
protected void UserAccounts_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
Guid id = (Guid)e.Keys[0];
GridViewRow row = UserAccounts.Rows[e.RowIndex];
string fullname = (row.FindControl("txtFullname") as TextBox).Text;
string email = (row.FindControl("txtEmail") as TextBox).Text;
string phone = (row.FindControl("txtPhone") as TextBox).Text;
string comment = (row.FindControl("txtComment") as TextBox).Text;
bool isApproved = (row.FindControl("chkIsApproved") as CheckBox).Checked;
MembershipUser user = Membership.GetUser(id);
if (user == null) return;
user.Email = email;
user.Comment = comment;
user.IsApproved = isApproved;
Membership.UpdateUser(user);
aspnet_UserProfilesBLL bll = new aspnet_UserProfilesBLL();
bll.UpdateProfile(user.UserName, fullname, phone);
//LinqDataSource1.DataBind();
}
示例14: AdminDoctorView_RowUpdating
protected void AdminDoctorView_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
BusinessLayer businessLyerObj = new BusinessLayer();
string connectString = ConfigurationManager.AppSettings.Get("connString");
int index = e.RowIndex;
businessLyerObj.ApproveDoctor(AdminDoctorView.DataKeys[index].Value.ToString(), connectString);
}
示例15: GridView1_RowUpdating
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
//Get the CheckBox in the row that is being updated
CheckBox adminbox = (CheckBox)GridView1.Rows[e.RowIndex].FindControl("CheckBox1");
//Get the User
string username = GridView1.Rows[e.RowIndex].Cells[0].Text;
//get the username from the datakeys collection instead
//string username1 = GridView1.DataKeys[e.RowIndex].Value.ToString();
//if the checkbox is checked and the user is not currently an admin, add the user to the admin role
if(adminbox.Checked && Roles.IsUserInRole(username,"Admin"))
{
Roles.AddUserToRole(username, "Admin");
}
//if the checkebox is unchecked and the user is currently an admin, remove the user from the Admin role
if(!adminbox.Checked && Roles.IsUserInRole(username, "Admin"))
{
Roles.RemoveUserFromRole(username, "Admin");
}
GridView1.EditIndex = -1;
GridView1.DataBind();
}