when admin approve/reject any document once then when admin again login then he/she not be able to approve/reject documents again and dropdownlist will be disabled only for those documents which can be once approve/reject then when admin view any new documents then drop down will be enable and when admin approve/reject this document then it will be disable dropdownlist for not approve /reject again
for this i do this
code:
protected void OnRowDataBound
(object sender, GridViewRowEventArgs e
)
{
if (e.Row.RowType == DataControlRowType.DataRow
)
{
//Find the DropDownList in the Row
DropDownList abc = (e.Row.FindControl("DropDownList9") as DropDownList);
abc.Enabled = false; } }
but this code show me all dropdownlist are disable .
any solution how i will do this?
Loading
Sanjeeb LenkaPosted Nov 7, 2013, 11:26 PM
scropio gurlPosted Nov 8, 2013, 2:32 AM
Sanjeeb LenkaPosted Nov 8, 2013, 2:20 AM
scropio gurlPosted Nov 8, 2013, 2:16 AM
scropio gurlPosted Nov 8, 2013, 2:04 AM
Sanjeeb LenkaPosted Nov 8, 2013, 2:01 AM
i am only write the code for dropdown disable. and manually insert the data in table for test porpose
scropio gurlPosted Nov 8, 2013, 1:48 AM
and when i select pedning then how it disable?
can u please tell me
Sanjeeb LenkaPosted Nov 7, 2013, 11:37 PM
create table like this and change the connection string and query .
scropio gurlPosted Nov 7, 2013, 1:44 PM
Sanjeeb LenkaPosted Nov 7, 2013, 1:06 PM
i modified your code some places just check this
protected void GridView1_DataBound(object sender, EventArgs e)
{
foreach (GridViewRow gvRow in GrdFileApprove.Rows)
{
DropDownList ddlDepartment = gvRow.FindControl("DropDownList") as DropDownList;
HiddenField hfDepartmentId = gvRow.FindControl("hfDepartmentId") as HiddenField;
if (ddlDepartment != null && hfDepartmentId != null && hfDepartmentId.Value != string.Empty && Convert.ToInt32(hfDepartmentId.Value)!=3 )
{
ddlDepartment.SelectedValue = hfDepartmentId.Value.Trim();
ddlDepartment.Enabled = false;
}
}
}
scropio gurlPosted Nov 7, 2013, 12:52 PM
scropio gurlPosted Nov 7, 2013, 11:49 AM
i attached the file plz check it
Sanjeeb LenkaPosted Nov 7, 2013, 9:11 AM
scropio gurlPosted Nov 7, 2013, 8:31 AM
then when once approved /reject and again login then dropdownlist are always enabled...but i want this disabled
Sanjeeb LenkaPosted Nov 7, 2013, 4:06 AM
here i take a hiddenfield with dropdown and binding the database data to it:
Select
next in gridview databound event i will check the hiddnfield value and selcting the value and disabling the dropdown.
protected void GridView1_DataBound(object sender, EventArgs e)
{
foreach (GridViewRow gvRow in GridView1.Rows)
{
DropDownList ddlDepartment = gvRow.FindControl("DropDownList1") as DropDownList;
HiddenField hfDepartmentId = gvRow.FindControl("hfDepartmentId") as HiddenField;
if (ddlDepartment != null && hfDepartmentId != null && hfDepartmentId.Value != string.Empty)
{
ddlDepartment.SelectedValue = hfDepartmentId.Value.Trim();
ddlDepartment.Enabled = false;
}
}
}
scropio gurlPosted Nov 7, 2013, 2:47 AM
scropio gurlPosted Nov 7, 2013, 2:25 AM
approve
reject
Sanjeeb LenkaPosted Nov 7, 2013, 2:12 AM
and what the value you are storing in database in drop down.
scropio gurlPosted Nov 7, 2013, 1:59 AM
" Operator '||' cannot be applied to operands of type 'bool' and 'string' "
where as i have a submit code is
protected void Button1_Click(object sender, EventArgs e)
{
string connStr = ConfigurationManager.ConnectionStrings["mydms"].ConnectionString;
SqlConnection mySQLconnection = new SqlConnection(connStr);
if (mySQLconnection.State == ConnectionState.Closed)
{
mySQLconnection.Open();
}
foreach (GridViewRow row in GrdFileApprove.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
DropDownList DropDownListcontrol = row.FindControl("DropDownList4") as DropDownList;
SqlCommand cmd = new SqlCommand("approveddd", mySQLconnection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@DocID", SqlDbType.Int).Value = Convert.ToInt32((row.Cells[1].Text));
cmd.Parameters.Add("@ApproveID", SqlDbType.Int).Value = Convert.ToInt32(DropDownListcontrol.SelectedValue);
cmd.Parameters.Add("@ApproveBy", SqlDbType.VarChar, 50).Value = (Session["Login2"]);
cmd.ExecuteNonQuery();
DMSLIB.Doc myDoc = new DMSLIB.Doc();
myDoc.MarkDocAs(Convert.ToInt16(row.Cells[1].Text), Convert.ToInt32(DropDownListcontrol.SelectedValue));
}
else
{
apfi.Text = "Error";
}
}
if (mySQLconnection.State == ConnectionState.Open)
{
mySQLconnection.Close();
}
}
in this code when admin select approve/reject through dropdown then click submit button then action performed but when admin again login then this dropdown must disable
and when user upload new documnet and then admin login and see this upload documnet then dropdown must enable and when admin performed approve/reject then dropdown disable
r u understand my point?
Sanjeeb LenkaPosted Nov 7, 2013, 12:01 AM
try like this it may help you:
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//Find the DropDownList in the Row
DropDownList abc = (e.Row.FindControl("DropDownList9") as DropDownList);
if (abc.SelectedValue == "approve" || abc.SelectedValue == "reject")
abc.Enabled = false;
else
abc.Enabled = true;
}
}