Bineesh  Viswanath

Bineesh Viswanath

  • NA
  • 1k
  • 780.6k

ASP.NET DataGridView Fill Method

Aug 23 2013 5:07 AM
Sir, I need your help in GridView Fill Method.

I not need any  tutorial links. Here I posting my code as output.



Here I showing the output . Check the code for this below. This is getting in the btnSave_Click Event(see code below).




divisionId,divisionName and ClassName is not retrieving.


SQL Stored procedure:-


ALTER PROCEDURE  divisionViewAll
AS
SELECT    divisionId, divisionName, tbl_Class.className
FROM         tbl_Division
Inner join tbl_Class
ON tbl_Division.classId=tbl_Class.classId
ORDER BY className


DivisionSP.cs:-


public DataTable DivisionViewAll()
    {
        DataTable d = new DataTable();
        SqlDataAdapter a = new SqlDataAdapter("divisionViewAll", sqlCon);
        a.SelectCommand.CommandType = CommandType.StoredProcedure;
        a.Fill(d);
        return d;
    }

Division.aspx.cs :-

public void gridFill()
    {
        DataTable d = new DataTable();
        divisionSP spDiv = new divisionSP();
        d = spDiv.DivisionViewAll();
        dgvDivision.DataSource = d;
        dgvDivision.DataBind();
    }

btnSave_Click:-

protected void btnSave_Click(object sender, EventArgs e)
    {
        divisionSP spDiv = new divisionSP();
        divisionInfo InfoDiv = new divisionInfo();
        InfoDiv.divisionName = txtDivision.Text;
        InfoDiv.classId = decimal.Parse(cmbClassName.SelectedValue.ToString());
        spDiv.DivisionAdd(InfoDiv);
        mvDivision.ActiveViewIndex = 1;
        gridFill();
    }

My save function is working.

There is Two <asp:View> . grid is in 2nd View and Save function is in 1st.

help me in this topic.

Answers (11)