Hallo zusammen
Versuche seit nunmehr Tagen einen Datagrid in ein Tabstrip einzubauen, bisher jedoch ohne Erfolg. Der Tabstrip läuft zwar, der Datagrid läuft ebenfalls, aber sobald ich den Code merge, kommt zwar keine Fehlermeldung aber auch kein Datagrid. Wo könnte das Problem liegen?
Für eure Ideen wäre ich sehr dankbar.
Gruss und bis bald,
Pat
Mein Beispiel-Code:
<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Page Language="c#" AutoEventWireup="false" Codebehind="TabGrid.aspx.cs" Inherits="EPAF.Webtest" %>
<%@ Import namespace="Microsoft.Web.UI.WebControls" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<style>UNKNOWN {
FONT-SIZE: 10pt; FONT-FAMILY: Verdana
}
TABLE {
BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; WIDTH: 100%; BORDER-BOTTOM: 0px; HEIGHT: 100%
}
.header1 {
FONT-SIZE: 16pt; COLOR: blue
}
.header2 {
FONT-SIZE: 12pt; COLOR: blue
}
.intro {
FONT-SIZE: 10pt; WIDTH: 795px; COLOR: blue
}
</style>
</HEAD>
<body MS_POSITIONING="GridLayout">
<h1 class="header1"> </h1>
<form id="FileForm" method="post" runat="server">
<iewc:tabstrip id="CentralTab" runat="server" Height="24px" Width="894px" onselectedIndexChange="CentralTab_SelectedIndexChange"
autopostback="true" TabSelectedStyle="height:20px; border-bottom:none; border-left:1x solid black; border-top:1x solid black; background-color:#FFFFC0"
TabHoverStyle="height:20px; border-bottom:1px solid black; border-left:1x solid black; border-top:1x solid black; background-color:#FFFFC0;"
TabDefaultStyle="height:20px; font-size:7pt; font-family:verdana; border-bottom:1px solid black; padding:2px; border-left:1x solid black; border-top:1x solid black; background-color:white">
<iewc:Tab Text="Description" DefaultStyle="width:68px;text-align:center;" ID="TabDir"></iewc:Tab>
<iewc:Tab Text="Risks" DefaultStyle="width:68px;text-align:center;" ID="TabFile"></iewc:Tab>
<iewc:Tab Text="Interdependences" DefaultStyle="width:68px;text-align:center;" ID="TabEdit"></iewc:Tab>
<iewc:Tab Text="Project Plan" DefaultStyle="width:70px;text-align:center;" ID="TabUpload"></iewc:Tab>
<iewc:Tab Text="Organisation" DefaultStyle="width:68px;text-align:center;" ID="TabOrg"></iewc:Tab>
<iewc:Tab Text="Capex" DefaultStyle="width:68px;text-align:center;" ID="TabCapex"></iewc:Tab>
<iewc:Tab Text="Opex" DefaultStyle="width:68px;text-align:center;" ID="TabOpex"></iewc:Tab>
<iewc:Tab Text="Rev & CoS" DefaultStyle="width:68px;text-align:center;" ID="TabRevCos"></iewc:Tab>
<iewc:Tab Text="Financials" DefaultStyle="width:68px;text-align:center;" ID="TabFin"></iewc:Tab>
<iewc:Tab Text="Persons" DefaultStyle="width:68px;text-align:center;" ID="TabPers"></iewc:Tab>
<iewc:Tab Text="Signatures" DefaultStyle="width:68px;text-align:center;" ID="TabSign"></iewc:Tab>
<iewc:TabSeparator DefaultStyle="border-bottom:1px solid black;border-left:1x solid black;width:20px;height:0px;"></iewc:TabSeparator>
</iewc:tabstrip><iewc:multipage id="CentralPage" style="BORDER-TOP: medium none" runat="server" Height="450px" Width="894px"
BackColor="#FFFFC0" BorderWidth="1px" BorderStyle="Solid" selectedIndex="0">
<iewc
ageView id="PageList"></iewc
ageView>
<iewc
ageView></iewc
ageView>
<iewc
ageView></iewc
ageView>
<iewc
ageView></iewc
ageView>
<iewc
ageView>Test</iewc
ageView>
<iewc
ageView>Noch mehr Test</iewc
ageView>
<iewc
ageView>Ganz viel Test</iewc
ageView>
<iewc
ageView>Ungemein viel Test</iewc
ageView>
<iewc
ageView>Maximale Tests</iewc
ageView>
<iewc
ageView>
<asp
ataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 168px; POSITION: absolute; TOP: 128px"
runat="server" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" BackColor="White"
CellPadding="3" GridLines="Horizontal">
<SelectedItemStyle Font-Bold="True" ForeColor="#F7F7F7" BackColor="#738A9C"></SelectedItemStyle>
<AlternatingItemStyle BackColor="#F7F7F7"></AlternatingItemStyle>
<ItemStyle ForeColor="#4A3C8C" BackColor="#E7E7FF"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#F7F7F7" BackColor="#4A3C8C"></HeaderStyle>
<FooterStyle ForeColor="#4A3C8C" BackColor="#B5C7DE"></FooterStyle>
<Columns>
<asp:TemplateColumn HeaderText="Person">
<ItemTemplate>
<asp:Label runat="server" ID="Label1" NAME="Label1"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="Textbox1" NAME="Textbox1"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Department">
<ItemTemplate>
<asp:Label runat="server" ID="Label2" NAME="Label2"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="Textbox2" NAME="Textbox2"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle HorizontalAlign="Right" ForeColor="#4A3C8C" BackColor="#E7E7FF" Mode="NumericPages"></PagerStyle>
</asp
ataGrid>
</iewc
ageView>
<iewc
ageView></iewc
ageView>
</iewc:multipage></form>
</body>
</HTML>
---------------------------------------------------------------------------------------------------------
using System;
//using System.Text;
using System.IO;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Microsoft.Web.UI.WebControls;
using System.Data.OleDb;
namespace EPAF
{
/// <summary>
/// Zusammendfassende Beschreibung für _default.
/// </summary>
public class Webtest : System.Web.UI.Page
{
protected MultiPage CentralPage;
protected TabStrip CentralTab;
protected Label CurrentDirectory;
protected Label CurrentPath;
protected PlaceHolder FileShowBox;
protected Label FileName;
protected Label UploadDir;
protected Label UploadPath;
protected RadioButtonList Uploads;
protected HtmlGenericControl UploadControls;
public void CentralTab_SelectedIndexChange(Object sender, EventArgs e)
{
CentralPage.SelectedIndex = CentralTab.SelectedIndex;
if (CentralTab.SelectedIndex == 11)
{
// ModifyFormForUpload ();
}
}
//#region Web Form Designer generated code
//override protected void OnInit(EventArgs e)
//{
//
// CODEGEN: Dieser Aufruf ist für den ASP.NET Web Form-Designer erforderlich.
//
// InitializeComponent();
// base.OnInit(e);
}
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
//private void InitializeComponent()
//{
// this.CentralPage.SelectedIndexChange += new System.EventHandler(this.CentralPage_SelectedIndexChange);
// this.Load += new System.EventHandler(this.Page_Load);
//}
//#endregion
//}
}
public class datagridpage : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button btnAddPet;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.DataGrid datagrid;
private void Page_Load(object sender, System.EventArgs e)
{
// datagrid.AllowPaging = true;
// datagrid.PagerStyle.Mode = PagerMode.NumericPages;
// datagrid.PagerStyle.PageButtonCount = 2;
// datagrid.PageSize = 5;
if (!IsPostBack) ReadRecords();
// if (!Page.IsPostBack)
// {
// datagrid.DataBind();
// }
}
private void ReadRecords()
{
OleDbConnection conn = null;
OleDbDataReader reader = null;
try
{
conn = new OleDbConnection(
@"Provider=Microsoft.Jet.OLEDB.4.0; " +
@"Data Source=" + Server.MapPath("addresses/Addresses.mdb"));
conn.Open();
OleDbCommand cmd =
new OleDbCommand("Select * FROM Tbl_Address", conn);
reader = cmd.ExecuteReader();
datagrid.DataSource = reader;
datagrid.DataBind();
}
// catch (Exception e)
// {
// Response.Write(e.Message);
// Response.End();
// }
finally
{
if (reader != null) reader.Close();
if (conn != null) conn.Close();
}
}
private void btnAddPet_Click(object sender, System.EventArgs e)
{
string sql = "INSERT INTO Tbl_Address (Name, FName, E_Mail)"
+ " VALUES (\"new\", \"new\", \"new\")";
ExecuteNonQuery(sql);
ReadRecords();
}
private void ExecuteNonQuery(string sql)
{
OleDbConnection conn = null;
try
{
conn = new OleDbConnection(
@"Provider=Microsoft.Jet.OLEDB.4.0; " +
@"Data Source=" + Server.MapPath("addresses/Addresses.mdb"));
conn.Open();
OleDbCommand cmd = new OleDbCommand(sql, conn);
cmd.ExecuteNonQuery();
}
// catch (Exception e)
// {
// Response.Write(e.Message);
// Response.End();
// }
finally
{
if (conn != null) conn.Close();
}
}
private void datagrid_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
datagrid.EditItemIndex = -1;
ReadRecords();
}
private void datagrid_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
datagrid.EditItemIndex = e.Item.ItemIndex;
ReadRecords();
}
private void datagrid_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
int ID = (int) datagrid.DataKeys[(int) e.Item.ItemIndex];
string sql = "DELETE FROM Tbl_Address WHERE ID=" + ID;
ExecuteNonQuery(sql);
ReadRecords();
}
private void datagrid_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
int ID = (int) datagrid.DataKeys[(int) e.Item.ItemIndex];
string name = ((TextBox)e.Item.Cells[1].Controls[0]).Text;
string fname = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
string mail = ((TextBox)e.Item.Cells[3].Controls[1]).Text;
string street = ((TextBox)e.Item.Cells[4].Controls[0]).Text;
string plz = ((TextBox)e.Item.Cells[5].Controls[0]).Text;
string location = ((TextBox)e.Item.Cells[6].Controls[0]).Text;
string phone = ((TextBox)e.Item.Cells[7].Controls[0]).Text;
string mobile = ((TextBox)e.Item.Cells[8].Controls[0]).Text;
string sql =
"UPDATE Tbl_Address SET Name=\"" + name +
"\", FName=\"" + fname + "\", E_Mail=\"" + mail + "\", Street=\"" + street + "\", PLZ=\"" + plz + "\", Location=\"" + location + "\", Phone=\"" + phone + "\", Mobile=\"" + mobile + "\"" +
" WHERE ID=" + ID;
ExecuteNonQuery(sql);
datagrid.EditItemIndex = -1;
ReadRecords();
}
private void Button1_Click(object sender, System.EventArgs e)
{
Response.Redirect("http://localhost/Address_DB/WebForm2.aspx");
}
private void datagrid_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
//private void datagrid_PageIndexChanged(object source,System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
//{
// datagrid.CurrentPageIndex = e.NewPageIndex;
// datagrid.DataBind();
//}
}
Versuche seit nunmehr Tagen einen Datagrid in ein Tabstrip einzubauen, bisher jedoch ohne Erfolg. Der Tabstrip läuft zwar, der Datagrid läuft ebenfalls, aber sobald ich den Code merge, kommt zwar keine Fehlermeldung aber auch kein Datagrid. Wo könnte das Problem liegen?
Für eure Ideen wäre ich sehr dankbar.
Gruss und bis bald,
Pat
Mein Beispiel-Code:
<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Page Language="c#" AutoEventWireup="false" Codebehind="TabGrid.aspx.cs" Inherits="EPAF.Webtest" %>
<%@ Import namespace="Microsoft.Web.UI.WebControls" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<style>UNKNOWN {
FONT-SIZE: 10pt; FONT-FAMILY: Verdana
}
TABLE {
BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; WIDTH: 100%; BORDER-BOTTOM: 0px; HEIGHT: 100%
}
.header1 {
FONT-SIZE: 16pt; COLOR: blue
}
.header2 {
FONT-SIZE: 12pt; COLOR: blue
}
.intro {
FONT-SIZE: 10pt; WIDTH: 795px; COLOR: blue
}
</style>
</HEAD>
<body MS_POSITIONING="GridLayout">
<h1 class="header1"> </h1>
<form id="FileForm" method="post" runat="server">
<iewc:tabstrip id="CentralTab" runat="server" Height="24px" Width="894px" onselectedIndexChange="CentralTab_SelectedIndexChange"
autopostback="true" TabSelectedStyle="height:20px; border-bottom:none; border-left:1x solid black; border-top:1x solid black; background-color:#FFFFC0"
TabHoverStyle="height:20px; border-bottom:1px solid black; border-left:1x solid black; border-top:1x solid black; background-color:#FFFFC0;"
TabDefaultStyle="height:20px; font-size:7pt; font-family:verdana; border-bottom:1px solid black; padding:2px; border-left:1x solid black; border-top:1x solid black; background-color:white">
<iewc:Tab Text="Description" DefaultStyle="width:68px;text-align:center;" ID="TabDir"></iewc:Tab>
<iewc:Tab Text="Risks" DefaultStyle="width:68px;text-align:center;" ID="TabFile"></iewc:Tab>
<iewc:Tab Text="Interdependences" DefaultStyle="width:68px;text-align:center;" ID="TabEdit"></iewc:Tab>
<iewc:Tab Text="Project Plan" DefaultStyle="width:70px;text-align:center;" ID="TabUpload"></iewc:Tab>
<iewc:Tab Text="Organisation" DefaultStyle="width:68px;text-align:center;" ID="TabOrg"></iewc:Tab>
<iewc:Tab Text="Capex" DefaultStyle="width:68px;text-align:center;" ID="TabCapex"></iewc:Tab>
<iewc:Tab Text="Opex" DefaultStyle="width:68px;text-align:center;" ID="TabOpex"></iewc:Tab>
<iewc:Tab Text="Rev & CoS" DefaultStyle="width:68px;text-align:center;" ID="TabRevCos"></iewc:Tab>
<iewc:Tab Text="Financials" DefaultStyle="width:68px;text-align:center;" ID="TabFin"></iewc:Tab>
<iewc:Tab Text="Persons" DefaultStyle="width:68px;text-align:center;" ID="TabPers"></iewc:Tab>
<iewc:Tab Text="Signatures" DefaultStyle="width:68px;text-align:center;" ID="TabSign"></iewc:Tab>
<iewc:TabSeparator DefaultStyle="border-bottom:1px solid black;border-left:1x solid black;width:20px;height:0px;"></iewc:TabSeparator>
</iewc:tabstrip><iewc:multipage id="CentralPage" style="BORDER-TOP: medium none" runat="server" Height="450px" Width="894px"
BackColor="#FFFFC0" BorderWidth="1px" BorderStyle="Solid" selectedIndex="0">
<iewc


<iewc


<iewc


<iewc


<iewc


<iewc


<iewc


<iewc


<iewc


<iewc

<asp

runat="server" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" BackColor="White"
CellPadding="3" GridLines="Horizontal">
<SelectedItemStyle Font-Bold="True" ForeColor="#F7F7F7" BackColor="#738A9C"></SelectedItemStyle>
<AlternatingItemStyle BackColor="#F7F7F7"></AlternatingItemStyle>
<ItemStyle ForeColor="#4A3C8C" BackColor="#E7E7FF"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#F7F7F7" BackColor="#4A3C8C"></HeaderStyle>
<FooterStyle ForeColor="#4A3C8C" BackColor="#B5C7DE"></FooterStyle>
<Columns>
<asp:TemplateColumn HeaderText="Person">
<ItemTemplate>
<asp:Label runat="server" ID="Label1" NAME="Label1"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="Textbox1" NAME="Textbox1"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Department">
<ItemTemplate>
<asp:Label runat="server" ID="Label2" NAME="Label2"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="Textbox2" NAME="Textbox2"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle HorizontalAlign="Right" ForeColor="#4A3C8C" BackColor="#E7E7FF" Mode="NumericPages"></PagerStyle>
</asp

</iewc

<iewc


</iewc:multipage></form>
</body>
</HTML>
---------------------------------------------------------------------------------------------------------
using System;
//using System.Text;
using System.IO;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Microsoft.Web.UI.WebControls;
using System.Data.OleDb;
namespace EPAF
{
/// <summary>
/// Zusammendfassende Beschreibung für _default.
/// </summary>
public class Webtest : System.Web.UI.Page
{
protected MultiPage CentralPage;
protected TabStrip CentralTab;
protected Label CurrentDirectory;
protected Label CurrentPath;
protected PlaceHolder FileShowBox;
protected Label FileName;
protected Label UploadDir;
protected Label UploadPath;
protected RadioButtonList Uploads;
protected HtmlGenericControl UploadControls;
public void CentralTab_SelectedIndexChange(Object sender, EventArgs e)
{
CentralPage.SelectedIndex = CentralTab.SelectedIndex;
if (CentralTab.SelectedIndex == 11)
{
// ModifyFormForUpload ();
}
}
//#region Web Form Designer generated code
//override protected void OnInit(EventArgs e)
//{
//
// CODEGEN: Dieser Aufruf ist für den ASP.NET Web Form-Designer erforderlich.
//
// InitializeComponent();
// base.OnInit(e);
}
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
//private void InitializeComponent()
//{
// this.CentralPage.SelectedIndexChange += new System.EventHandler(this.CentralPage_SelectedIndexChange);
// this.Load += new System.EventHandler(this.Page_Load);
//}
//#endregion
//}
}
public class datagridpage : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button btnAddPet;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.DataGrid datagrid;
private void Page_Load(object sender, System.EventArgs e)
{
// datagrid.AllowPaging = true;
// datagrid.PagerStyle.Mode = PagerMode.NumericPages;
// datagrid.PagerStyle.PageButtonCount = 2;
// datagrid.PageSize = 5;
if (!IsPostBack) ReadRecords();
// if (!Page.IsPostBack)
// {
// datagrid.DataBind();
// }
}
private void ReadRecords()
{
OleDbConnection conn = null;
OleDbDataReader reader = null;
try
{
conn = new OleDbConnection(
@"Provider=Microsoft.Jet.OLEDB.4.0; " +
@"Data Source=" + Server.MapPath("addresses/Addresses.mdb"));
conn.Open();
OleDbCommand cmd =
new OleDbCommand("Select * FROM Tbl_Address", conn);
reader = cmd.ExecuteReader();
datagrid.DataSource = reader;
datagrid.DataBind();
}
// catch (Exception e)
// {
// Response.Write(e.Message);
// Response.End();
// }
finally
{
if (reader != null) reader.Close();
if (conn != null) conn.Close();
}
}
private void btnAddPet_Click(object sender, System.EventArgs e)
{
string sql = "INSERT INTO Tbl_Address (Name, FName, E_Mail)"
+ " VALUES (\"new\", \"new\", \"new\")";
ExecuteNonQuery(sql);
ReadRecords();
}
private void ExecuteNonQuery(string sql)
{
OleDbConnection conn = null;
try
{
conn = new OleDbConnection(
@"Provider=Microsoft.Jet.OLEDB.4.0; " +
@"Data Source=" + Server.MapPath("addresses/Addresses.mdb"));
conn.Open();
OleDbCommand cmd = new OleDbCommand(sql, conn);
cmd.ExecuteNonQuery();
}
// catch (Exception e)
// {
// Response.Write(e.Message);
// Response.End();
// }
finally
{
if (conn != null) conn.Close();
}
}
private void datagrid_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
datagrid.EditItemIndex = -1;
ReadRecords();
}
private void datagrid_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
datagrid.EditItemIndex = e.Item.ItemIndex;
ReadRecords();
}
private void datagrid_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
int ID = (int) datagrid.DataKeys[(int) e.Item.ItemIndex];
string sql = "DELETE FROM Tbl_Address WHERE ID=" + ID;
ExecuteNonQuery(sql);
ReadRecords();
}
private void datagrid_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
int ID = (int) datagrid.DataKeys[(int) e.Item.ItemIndex];
string name = ((TextBox)e.Item.Cells[1].Controls[0]).Text;
string fname = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
string mail = ((TextBox)e.Item.Cells[3].Controls[1]).Text;
string street = ((TextBox)e.Item.Cells[4].Controls[0]).Text;
string plz = ((TextBox)e.Item.Cells[5].Controls[0]).Text;
string location = ((TextBox)e.Item.Cells[6].Controls[0]).Text;
string phone = ((TextBox)e.Item.Cells[7].Controls[0]).Text;
string mobile = ((TextBox)e.Item.Cells[8].Controls[0]).Text;
string sql =
"UPDATE Tbl_Address SET Name=\"" + name +
"\", FName=\"" + fname + "\", E_Mail=\"" + mail + "\", Street=\"" + street + "\", PLZ=\"" + plz + "\", Location=\"" + location + "\", Phone=\"" + phone + "\", Mobile=\"" + mobile + "\"" +
" WHERE ID=" + ID;
ExecuteNonQuery(sql);
datagrid.EditItemIndex = -1;
ReadRecords();
}
private void Button1_Click(object sender, System.EventArgs e)
{
Response.Redirect("http://localhost/Address_DB/WebForm2.aspx");
}
private void datagrid_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
//private void datagrid_PageIndexChanged(object source,System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
//{
// datagrid.CurrentPageIndex = e.NewPageIndex;
// datagrid.DataBind();
//}
}