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
help me in this topic.

Iftikar HussainPosted Aug 23, 2013, 6:01 AM
try like this
CommandName="Select">Select
Bineesh ViswanathPosted Aug 23, 2013, 6:31 AM
Here is my current output:-
Sanjeeb LenkaPosted Aug 23, 2013, 6:10 AM
you are not binding the column to grid item tamplate. try this:
CellPadding="4" CellSpacing="2" ForeColor="Black" HorizontalAlign="Center" PageSize="8">
Bineesh ViswanathPosted Aug 23, 2013, 5:57 AM
It is within a
BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2"
ForeColor="Black" HorizontalAlign="Center" PageSize="8">
Iftikar HussainPosted Aug 23, 2013, 5:43 AM
public void gridFill()
{
divisionSP spDiv = new divisionSP();
DataTable d = spDiv.DivisionViewAll();
dgvDivision.DataSource = d;
dgvDivision.DataBind();
}
Regards,
Iftikar
Sanjeeb LenkaPosted Aug 23, 2013, 5:43 AM
Iftikar HussainPosted Aug 23, 2013, 5:42 AM
Regards,
Iftikar
Bineesh ViswanathPosted Aug 23, 2013, 5:40 AM
Now what would be the code in:-
public void gridFill()
{
?
}
Bineesh ViswanathPosted Aug 23, 2013, 5:34 AM
Here I changed my SQL SP to:-
ALTER PROCEDURE divisionViewAll
AS
SELECT divisionName, classId, divisionId
FROM tbl_Division
Though no change in output. Here it is:-
I am showing you another GridView that is working properly.Here that GridView:-
The forth Grid has no dataBound fields. Is this a cause to not getting output?
Vishwas KadamannayaPosted Aug 23, 2013, 5:28 AM
try this.. you should use DataSet for filling into a SqlDataAdapter.
public DataSet DivisionViewAll()
{
DataSet d = new DataSet();
SqlDataAdapter a = new SqlDataAdapter("divisionViewAll", sqlCon);
a.SelectCommand.CommandType = CommandType.StoredProcedure;
a.Fill(d);
return d;
}
Iftikar HussainPosted Aug 23, 2013, 5:21 AM
Not clear about your query? can you explain bit more
Regards,
Iftikar