Click here to Skip to main content
15,913,685 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Student_FeedbackForm.aspx.cs" MasterPageFile ="~/Master_Student_Form.master" Inherits="Student_FeedbackForm" %>

<asp:Content ContentPlaceHolderID="ContentPlaceHolder1";ID="cnt1" runat="server">

XML
<table align="center" style="width: 31%">
       <tr>
           <td>
             <asp:Label ID="lblMsg" Text ="" runat ="server" Font-Bold="True" ForeColor="Red"></asp:Label>
           </td>
       </tr>
    <tr>
       <td>
           <asp:Label ID="StudentFeedbackForm" Text = "Student Feedback Form" runat ="server" Font-Bold="True" ForeColor="Blue"></asp:Label>
       </td>
    </tr>
    </table>

       <table align="center" style="width:80%">
      <tr>

           <td class="style1">
              <asp:Label ID= "lblCourse" runat= "Server" Font-Bold="True" ForeColor="Blue" Width="75px" Font-Names="Verdana">Course</asp:Label>
              <asp:DropDownList ID="ddlcourse" runat="server" AutoPostBack="true" Width="190px"
                   OnSelectedIndexChanged="ddlcourse_SelectedIndexChanged" Font-Names="Verdana"></asp:DropDownList>
           </td>
           <td >
             <asp:Label ID= "lblBatch" runat= "Server" Font-Bold="True" ForeColor="Blue"
                   Font-Names="Verdana">Batch</asp:Label>
             <asp:DropDownList ID="ddlbatch" runat = "server"
             AutoPostBack ="true" Width ="243px" Font-Names="Verdana" Height="20px"
                   onselectedindexchanged="ddlbatch_SelectedIndexChanged"></asp:DropDownList>
           </td>
      </tr>




XML
<asp:Panel id="pnlfac" runat="server" backcolor="Beige" ScrollBars="Auto" bordercolor ="Black"
      borderstyle="Solid" borderwidth="1px" height="226px" Width="1095px"
      HorizontalAlign="Center">
          <asp:GridView id="gvfaculty" runat="server" backcolor="LightGoldenrodYellow"
            BorderColor="Tan" width="1090px" ForeColor="Black" AutoGenerateColumns ="False"
                EnableModelValidation="True"
              OnRowCreated ="gvfaculty_RowCreated">
                 <FooterStyle BackColor="Tan"/><AlternatingRowStyle BackColor="PaleGoldenrod" />
                 <Columns>
                 <asp:BoundField DataField="Facname" HeaderText="Faculty" >
                     <ItemStyle Font-Names="Verdana" Font-Size="Small" HorizontalAlign="Left" />
                 </asp:BoundField>
                 <asp:BoundField DataField="Facid" HeaderText="Facultyid" />
                 <asp:TemplateField HeaderText="Does the Faculty come well prepared for his subject">
                 <ItemTemplate>
                 <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="true">
                 </asp:DropDownList>
                 </ItemTemplate>
                     <ItemStyle Font-Names="Verdana" Font-Size="Small" HorizontalAlign="Left" />
                 </asp:TemplateField>

                 <asp:TemplateField HeaderText="Is he loud and clear in his speech">


                  <ItemTemplate>
                  <asp:DropDownList ID="DropDownList2" runat="server" AppendDataBoundItems="true"></asp:DropDownList>
                  </ItemTemplate>
                  </asp:TemplateField>


<HeaderStyle BackColor="Tan" Font-Bold="True" HorizontalAlign="Left" Font-Names="Verdana" Font-Size="Small" /><pagerstyle backcolor="PaleGoldenrod" forecolor="DarkSlateBlue" horizontalalign="Center"><SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />




ddlbatch selected index change code as follows

protected void ddlbatch_SelectedIndexChanged(object sender, EventArgs e)
{
lblMsg.Text = "";
try
{
C#
lblMsg.Text = "";
        try
        {
             sql = "SELECT sel.fac_id as Facid, fac.facname as facname,fac.type FROM Tb_Presea_Feedback_Launch l,Tb_Presea_Faculty_Selected sel,";
            sql = sql + "Tb_Presea_Faculty_Master fac where l.launch_id = sel.launch_id and l.batch_id = '" + ddlbatch.SelectedValue.ToString().Trim() + "'";
            sql = sql + "and l.active = 'A' and fac.facid = sel.fac_id and fac.type = 'F'";
            DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("facname", typeof(string)));
            dt.Columns.Add(new DataColumn("Facid", typeof(string)));
            dr = scon.ReadSql(sql);
            gvfaculty.DataSource = dr;
            gvfaculty.DataBind();

             if (gvfaculty.Rows.Count <= 0)
            {
                lblMsg.Text = "Feedback is not launched for this batch";
                ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('Feedback is not launched for this batch')", true);
                return;
            }
        }
        catch (Exception e1)
        {
            lblMsg.Text = e1.Message.ToString();
            return;
        }


setintialrow();
}
catch (Exception ex)
{
lblMsg.Text = "Unable to Load Data" + ex.Message.ToString();
return;
}
}

In the run mode screen as follows

Studentfeedback form
Course ddlcourse Batch ddlbatch

When i select the ddl course in batch all batch details will be displayed and when i select the ddlbatch the gridview will be displayed.


But when i use the update panel in source as follows

XML
<asp:UpdatePanel ID = "UpdatePanel1" ChildrenAsTriggers="true" runat ="server">
             <ContentTemplate>


<asp:UpdatePanel ID = "UpdatePanel1" ChildrenAsTriggers="true" runat ="server">
<contenttemplate>



<asp:Label ID="lblMsg" Text ="" runat ="server" Font-Bold="True" ForeColor="Red">
<asp:Label ID="StudentFeedbackForm" Text = "Student Feedback Form" runat ="server" Font-Bold="True" ForeColor="Blue">





<asp:Label ID= "lblCourse" runat= "Server" Font-Bold="True" ForeColor="Blue" Width="75px" Font-Names="Verdana">Course
<asp:DropDownList ID="ddlcourse" runat="server" AutoPostBack="true" Width="190px"
OnSelectedIndexChanged="ddlcourse_SelectedIndexChanged" Font-Names="Verdana">
<asp:Label ID= "lblBatch" runat= "Server" Font-Bold="True" ForeColor="Blue"
Font-Names="Verdana">Batch
<asp:DropDownList ID="ddlbatch" runat = "server"
AutoPostBack ="true" Width ="243px" Font-Names="Verdana" Height="20px"
onselectedindexchanged="ddlbatch_SelectedIndexChanged">
<asp:RequiredFieldValidator ID="RequiredFieldValidator21" runat="server"
ErrorMessage="Please Select Batch" ControlToValidate="ddlbatch"
Font-Names="Verdana" Font-Size="Medium"
InitialValue="--Please Select the Batch Date--">
<asp:UpdateProgress ID="UpdateProgress2" runat="server">
<progresstemplate>
<asp:Label ID="Label20" runat="server" Font-Size="Large"
Text="Please Wait ...">
<img alt="" src ="images/Prog_2.gif"
style="width: 405px; height: 78px" />






In the run mode screen as follows

Studentfeedback form
Course ddlcourse Batch ddlbatch

When i select the ddl course in batch all batch details will be displayed and when i select the ddlbatch the gridview will not be displayed.

for that how can i do in asp.net using c#.
Posted

1 solution

XML
t sounds like you may not be using the UpdatePanel feature properly. If you have the UpdatePanel set to update when children fire events, only the UpdatePanel should refresh, not the entire page. The code below seems to behave similar to what you are seeking. When changing the drop down, only the update panel posts back to the server and when you refresh the page, you can get the value out of the session.

ASPX CODE

<form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
        Current Time: <asp:Label ID="lblTime" runat="server" /><br />
        Session Value: <asp:Label ID="lblSessionValue" runat="server" /><br />
        <br />
        <asp:UpdatePanel ID="upSetSession" runat="server">
            <ContentTemplate>
                <asp:DropDownList ID="ddlMyList" runat="server"
                    onselectedindexchanged="ddlMyList_SelectedIndexChanged"
                    AutoPostBack="true">
                    <asp:ListItem>Select One</asp:ListItem>
                    <asp:ListItem>Maybe</asp:ListItem>
                    <asp:ListItem>Yes</asp:ListItem>
                </asp:DropDownList>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="ddlMyList"
                    EventName="SelectedIndexChanged" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
</form>


CODE BEHIND

C#
protected void Page_Load(object sender, EventArgs e)
    {
        this.lblTime.Text = DateTime.Now.ToShortTimeString();
        if (Session["MyValue"] != null)
            this.lblSessionValue.Text = Session["MyValue"].ToString();
    }

    protected void ddlMyList_SelectedIndexChanged(object sender, EventArgs e)
    {
        Session.Remove("MyValue");
        Session.Add("MyValue", this.ddlMyList.SelectedValue);
    }
 
Share this answer
 

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