Click here to Skip to main content
14,932,670 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
My aspx code
ASP.NET
<asp:GridView ID="GridView1" runat="server"
OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowCommand="GridView1_RowCommand"
OnRowDataBound="GridView1_RowDataBound"
OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing"
OnRowUpdating="GridView1_RowUpdating";
<asp:TemplateField HeaderText="SNo" HeaderStyle-Width="10%">
<itemtemplate>
<asp:Label ID="lblName1" runat="server" Text='<%#Eval("SNo") %>'>
</itemtemplate>

<asp:TemplateField HeaderText="Compliance" HeaderStyle-Width="10%">
<itemtemplate>
<asp:Label ID="lblDepartment"   runat="server" Text='<%#Eval("Compliance") %>'>
</itemtemplate>
<edititemtemplate>
<asp:DropDownList ID="DropDownListDepartment" runat="server"
Width="60"  AutoPostBack="true" >
</edititemtemplate>
<footertemplate>
<asp:DropDownList ID="DropDownListAddDepartment" runat="server"
Width="60">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*"
 ControlToValidate="DropDownListAddDepartment" 
ValidationGroup="valGrp">
</footertemplate>


<asp:TemplateField HeaderText="Marks Alloted" HeaderStyle-Width="10%">
<itemtemplate>
<asp:Label ID="lblMarks" runat="server" Width="50px" Text='<%#Eval("Marks") %>' >
</itemtemplate>
<footertemplate>
<asp:TextBox ID="txtAddMarks"  runat="server"  Width="50px">

My aspx.cs code for dropdownlist
C#
private DataTable GetEmpDept()
{
    //Get Employee department
    DataTable dt = new DataTable();
    dt.Columns.Add("DepName");
    DataRow rw1 = dt.NewRow();
    rw1[0] = "Yes";
    dt.Rows.Add(rw1);
    DataRow rw2 = dt.NewRow();
    rw2[0] = "No";
    dt.Rows.Add(rw2);
    DataRow rw3 = dt.NewRow();
    rw3[0] = "NA";
    dt.Rows.Add(rw3);
    return dt;
}


What I have tried:

Now I want show Marks = 1 in lblMarks when lblDepartment selected value is "Yes"..
Posted
Updated 4-Mar-16 11:52am
v4
Comments
   
Could you please post the mark up again inside pre tags? Looks like it is terminating after a point.
Nagaraju Kukkudala 4-Mar-16 1:24am
   
<%--Department--%>
<asp:TemplateField HeaderText="Compliance" HeaderStyle-Width="10%">
<itemtemplate>
<asp:Label ID="lblDepartment" runat="server" Text='<%#Eval("Compliance") %>'>

<edititemtemplate>
<asp:DropDownList ID="DropDownListDepartment" runat="server"
Width="60" AutoPostBack="true" >

<footertemplate>
<asp:DropDownList ID="DropDownListAddDepartment" runat="server"
Width="60">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*"
ControlToValidate="DropDownListAddDepartment"
ValidationGroup="valGrp">



<asp:TemplateField HeaderText="Marks Alloted" HeaderStyle-Width="10%">
<itemtemplate>
<asp:Label ID="lblMarks" runat="server" Width="50px" Text='<%#Eval("Marks") %>' >
Sinisa Hajnal 4-Mar-16 3:44am
   
You have autopostback = true on your dropdownlist. What happens when you change the value? Do you get an error, it doesn't trigger or what? You don't have any event handlers on the dropdown so it is normal that it will not change anything (but it should still cause postback).

1 solution

Set AutoPostback = true on the dropdownlist control
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900