Hi, I am doing a web application using .net visual studio c#. In the status column, under the footer, i have a drop down list in which user can select either 'Open, Close or Na'. I have bind the drop down list to a method I have defiend. However the drop down list selection is being chng to: System.Data.DataRow.View. This value is able to be inserted into the database.
However, by right the ddl shld be populated with:
Open
Close
NA
instead of System.Data.DataRow.View.
This is the database.cs responsible for inserting records to database:
C# Copy
checklist
public bool
Insert_Checklist (string itemID, string item,
string procedureOwner, string status, string contractID )
{
SqlCommand cmd_checklist = new
SqlCommand();
cmd_checklist.CommandText = "[VRM].[INSERT_Checklist]" ;
cmd_checklist.CommandType = CommandType.StoredProcedure;
cmd_checklist.Parameters.Clear();
SqlParameter sqlParaItemID = new
SqlParameter("@itemID" ,
SqlDbType.VarChar, 10 );
sqlParaItemID.Value = itemID;
cmd_checklist.Parameters.Add(sqlParaItemID);
SqlParameter sqlParaItem = new
SqlParameter("@item" ,
SqlDbType.VarChar, 20 );
sqlParaItem.Value = item;
cmd_checklist.Parameters.Add(sqlParaItem);
SqlParameter sqlParaProcedureOwner =
new SqlParameter("@procedureOwner" , SqlDbType.VarChar,
30 );
sqlParaProcedureOwner.Value = procedureOwner;
cmd_checklist.Parameters.Add(sqlParaProcedureOwner);
SqlParameter sqlParaStatus = new
SqlParameter("@status" ,
SqlDbType.VarChar, 10 );
sqlParaStatus.Value = status;
cmd_checklist.Parameters.Add(sqlParaStatus);
SqlParameter sqlParaContractID = new
SqlParameter("@contractID" ,
SqlDbType.VarChar, 10 );
sqlParaContractID.Value = contractID;
cmd_checklist.Parameters.Add(sqlParaContractID);
return executeNotQuery(cmd_checklist);
}
This is the stored procedure for insert:
SQL Copy
ALTER PROCEDURE [VRM].[INSERT_Checklist]
(
@itemID varchar (10 ),
@item varchar (20 ),
@procedureOwner varchar (30 ),
@status varchar (10 ),
@contractID varchar (10 )
)
AS
BEGIN
INSERT INTO VRM.Checklist VALUES (@itemID ,
@item , @procedureOwner , @status , @contractID )
END
This is the business logic:
TypeScript Copy
protected void
gvChecklist_RowDataBound (object sender, GridViewRowEventArgs e )
{
if (e.Row .RowType == DataControlRowType .Footer )
{
DropDownList cmbStatus = (DropDownList )e.Row .FindControl ("cmbStatus" );
cmbStatus.DataSource = vrmdb.Get _Status();
cmbStatus.DataBind ();
}
}
Thanks for ur help all these while^^
Raghavendra URank #1,371 · 1.2K reputationPosted Feb 11, 2011, 6:27 PM EST
protected void gvChecklist_RowDataBound(object sender,GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Footer) { DropDownList cmbStatus = (DropDownList)e.Row.FindControl("cmbStatus"); cmbStatus.DataSource = vrmdb.Get_Status();}
}
Becky Bloomwood110 reputationPosted Feb 11, 2011, 6:33 PM EST