Announcement

Collapse
No announcement yet.

C# need a help.!

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • C# need a help.!

    Hallo ,

    kann jemand mir hilfen bei den Code mein fehler zu finden, Vielen Dank!

    using System;
    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;

    public partial class _Default : System.Web.UI.Page
    {
    CustomersCls customer = new CustomersCls();

    protected void Page_Load(object sender, EventArgs e)
    {

    If(!IsPostBack);
    {
    FillCustomerInGrid();
    }
    }

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
    private void FillCustomerInGrid()
    {
    DataTable dtCustomer= customer.Fetch();

    if (dtCustomer.Rows.Count>0)
    {
    GridView1.DataSource = dtCustomer;
    GridView1.DataBind();
    }
    else
    {
    dtCustomer.Rows.Add(dtCustomer.NewRow());
    GridView1.DataSource = dtCustomer;
    GridView1.DataBind();

    int TotalColumns = GridView1.Rows[0].Cells.Count;
    GridView1.Rows[0].Cells.Clear();
    GridView1.Rows[0].Cells.Add(new TableCell());
    GridView1.Rows[0].Cells[0].ColumnSpan = TotalColumns;
    GridView1.Rows[0].Cells[0].Text = "No Record Found";
    }
    }

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    DropDownList cmbType = (DropDownList)e.Row.FindControl("cmbType");

    if (cmbType != null)
    {
    cmbType.DataSource = customer.FetchCustomerType();
    cmbType.DataBind();
    cmbType.SelectedValue = GridView1.DataKeys[e.Row.RowIndex].Values[1].ToString();
    }
    }

    if (e.Row.RowType == DataControlRowType.Footer)
    {
    DropDownList cmbNewType = (DropDownList)e.Row.FindControl("cmbNewType");
    cmbNewType.DataSource = customer.FetchCustomerType();
    cmbNewType.DataBind();
    }

    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
    if (e.CommandName.Equals("AddNew"))
    {
    TextBox txtNewName = (TextBox)GridView1.FooterRow.FindControl("txtNewNa me");
    DropDownList cmbNewGender = (DropDownList)GridView1.FooterRow.FindControl("cmb NewGender");
    TextBox txtNewCity = (TextBox)GridView1.FooterRow.FindControl("txtNewCi ty");
    TextBox txtNewState = (TextBox)GridView1.FooterRow.FindControl("txtNewSt ate");
    DropDownList cmbNewType = (DropDownList)GridView1.FooterRow.FindControl("cmb NewType");

    customer.Insert(txtNewName.Text, cmbNewGender.SelectedValue, txtNewCity.Text, txtNewState.Text, cmbNewType.SelectedValue);
    FillCustomerInGrid();
    }
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
    cmbType.SelectedValue = GridView1.DataKeys[e.Row.RowIndex].Values[1].ToString();
    GridView1.EditIndex = e.NewEditIndex;
    FillCustomerInGrid();
    }
    protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
    GridView1.EditIndex = -1;
    FillCustomerInGrid();
    }
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
    TextBox txtName = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtName");
    DropDownList cmbGender = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("cmbGender");
    TextBox txtCity = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtCity");
    DropDownList cmbType = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("cmbType");

    customer.Update(GridView1.DataKeys[e.RowIndex].Values[0].ToString(), txtName.Text, cmbGender.SelectedValue, txtCity.Text, CustomerType.SelectedValue);
    GridView1.EditIndex = -1;
    FillCustomerInGrid();
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
    customer.Delete(GridView1.DataKeys[e.RowIndex].Values[0].ToString());
    FillCustomerInGrid();
    }
    }

  • #2
    Es wäre für die Helfenden zu wissen was Fehl läuft und was du eigentlich haben willst?

    Comment


    • #3
      Es geht da schon los:
      Code:
      protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
      {
      private void FillCustomerInGrid()
      {
      Deklaration einer Methode in einer anderen -> geht nicht!

      Außerdem: Code formatieren mit [highlight=c#]dein code[/highlight]

      mfG Gü
      "Any fool can write code that a computer can understand. Good programmers write code that humans can understand". - Martin Fowler

      Comment


      • #4
        ich habe C#.NET Web application , da ist ein fehler zeigt beim Run "}".

        in meine meinung sollte es nur ein mal in namespace sein aber, der zeigt es bei ersten class das fehler ist.

        Comment


        • #5
          hier ist the webseit, wo ich versucht habe das code zu kopieren

          Comment


          • #6
            Wenn schon kopieren dann richtig.
            "Any fool can write code that a computer can understand. Good programmers write code that humans can understand". - Martin Fowler

            Comment


            • #7
              Hey Gfoidly

              wenn ich es wusste

              den hatte ich hier nichts zu suchen, sorry aber bin ich anfänger ud hab kaum erfahrung in c# programming.

              Greetz monti

              Comment

              Working...
              X