|
 |
aspx thread: Editing data with datagridcontrol
Message #1 by "Frank Tichy" <tichy@s...> on Fri, 26 Oct 2001 11:29:13 +0200
|
|
Hi list,
I'm pretty new to asp.net and especially to c#. So even if my question seems
dumb please go easy on me.
I have the following code:
<%@ Page language="c#" debug="true" %>
<!-- #include virtual="/functions/functions.aspx" -->
<%
if (Page.IsPostBack)
{
/*
// Funktionen für die Edit, Update und Cancel-Links
// *************************************************
DoItemEdit(object sender, System.EventArgs e)
DoItemCancel(object sender, System.EventArgs e)
DoItemUpdate(object sender, System.EventArgs e)
*/
}
else
{
//Datenbankverbindung oeffnen
proinfo.Open();
//SQL String deklarieren und Statement und zuweisen
string StrSqlTel;
StrSqlTel = "SELECT PER_NACHNAME, PER_VORNAME, PER_TEL FROM PERSONAL
WHERE PER_AKTIV = '1' ORDER BY PER_NACHNAME";
//Dataset erstellen
DataSet MyDataSet = new DataSet();
SqlDataAdapter oCommand = new SqlDataAdapter(StrSqlTel,proinfo);
oCommand.Fill(MyDataSet,"PERSONAL");
string status = ("True");
//Datenbankverbindung schliessen
proinfo.Close();
//Dataset mit Datagrid verbinden
TelGrid.DataSource = MyDataSet.Tables["PERSONAL"].DefaultView;
TelGrid.DataBind();
}
%>
--------------------------
I tried to convert the example given in Professional ASP.Net(which is in vb)
page 335 to c#.
How do I convert the sub DoItemEdit()... to a c# class or something similar?
Any help is very much appreciated.
Kind regards
Frank Tichy a.k.a. FFVT
________________________________
Siller AG
Südstrasse 90
74072 Heilbronn
Tel.: +49 (0) 7131 / 9967-733
mailto:tichy@s...
http://www.siller.de
http://www.palmandmore.de
Postadresse:
Wannenäckerstrasse 43
74078 Heilbronn
Message #2 by "Chris Scott" <chris@e...> on Fri, 26 Oct 2001 13:22:08 -0700
|
|
Hi Frank,
A sub is equivalent to a void C# method...
public void DoItemEdit(object objSource, DataGridCommandEventArgs objArgs)
{
lblSQL.Text="";
MyDataGrid.EditItemIndex=objArgs.Item.ItemIndex;
BindDataGrid();
}
HTH
Chris
----- Original Message -----
From: "Frank Tichy" <tichy@s...>
To: "ASP+" <aspx@p...>
Sent: Friday, October 26, 2001 2:29 AM
Subject: [aspx] Editing data with datagridcontrol
> Hi list,
>
> I'm pretty new to asp.net and especially to c#. So even if my question
seems
> dumb please go easy on me.
> I have the following code:
> <%@ Page language="c#" debug="true" %>
> <!-- #include virtual="/functions/functions.aspx" -->
> <%
> if (Page.IsPostBack)
> {
> /*
> // Funktionen fr die Edit, Update und Cancel-Links
> // *************************************************
>
> DoItemEdit(object sender, System.EventArgs e)
>
> DoItemCancel(object sender, System.EventArgs e)
>
> DoItemUpdate(object sender, System.EventArgs e)
> */
> }
> else
> {
> //Datenbankverbindung oeffnen
> proinfo.Open();
>
> //SQL String deklarieren und Statement und zuweisen
> string StrSqlTel;
> StrSqlTel = "SELECT PER_NACHNAME, PER_VORNAME, PER_TEL FROM PERSONAL
> WHERE PER_AKTIV = '1' ORDER BY PER_NACHNAME";
>
> //Dataset erstellen
> DataSet MyDataSet = new DataSet();
> SqlDataAdapter oCommand = new SqlDataAdapter(StrSqlTel,proinfo);
> oCommand.Fill(MyDataSet,"PERSONAL");
> string status = ("True");
> //Datenbankverbindung schliessen
> proinfo.Close();
>
> //Dataset mit Datagrid verbinden
> TelGrid.DataSource = MyDataSet.Tables["PERSONAL"].DefaultView;
> TelGrid.DataBind();
> }
>
>
> %>
>
> --------------------------
> I tried to convert the example given in Professional ASP.Net(which is in
vb)
> page 335 to c#.
> How do I convert the sub DoItemEdit()... to a c# class or something
similar?
>
> Any help is very much appreciated.
>
> Kind regards
> Frank Tichy a.k.a. FFVT
>
> ________________________________
> Siller AG
> Sdstrasse 90
> 74072 Heilbronn
>
> Tel.: +49 (0) 7131 / 9967-733
> mailto:tichy@s...
> http://www.siller.de
> http://www.palmandmore.de
>
> Postadresse:
> Wannenckerstrasse 43
> 74078 Heilbronn
>
>
>
|
|
 |