Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
hello sir/mam
i have two list radiobutton list one for quesid and second for option of those ques
and one grid view table
and one drop downlist of subjects
when i select one item of that dropdownlist then it will work properly but when i select second item of dropdown list then it will not populate refersh grid view as i want.
when i select item then item will stored in gridview on button click but when i selected second item then it will not populate refersh radiobutton list and grid view.
plz me .
 
here is my code aspx code
 
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web
Imports System.Web.UI.WebControls.GridView
Partial Class _Default
    Inherits System.Web.UI.Page
    Dim con As SqlConnection
    Dim cm As SqlCommand
    Dim da As SqlDataAdapter
    Dim dt As DataTable
    Dim ds As DataSet
    Dim rs As String
    Dim ip, cr, b1, b2, s1 As String
    Dim i, c, j, op, trans, subj As Integer
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.b_save.Visible = True
        con = New SqlConnection("Data Source=.;Initial Catalog=appraisal;User ID=sa;Password=database")
        con.Open()
        If Not IsPostBack Then
            getques()
            getacdmic_detail()
        End If
    End Sub
    'reterive subj_name from database
    Public Sub getacdmic_detail()
        cr = Session("course").ToString
        b1 = Session("branch").ToString
        b2 = Session("batch").ToString
        s1 = Session("sem").ToString
        cm = New SqlCommand("SELECT   s.subj_name FROM faculty_subject_link_mst f INNER JOIN subj_mst s ON f.subjcd = s.subjcd INNER JOIN V_EmpMstDtl e ON f.emp_id = e.EmpId WHERE f.course_name = '" & cr.ToString & "' AND f.branch_name = '" & b1.ToString & "' AND f.sem_dcd = '" & s1.ToString & "' AND f.batch_name = '" & b2.ToString & "'", con)
        da = New SqlDataAdapter(cm)
        ds = New DataSet
        da.Fill(ds, "fs")
        subj = ds.Tables("fs").Rows.Count - 1
        'dl_sub.Items.Clear()
        'dl_sub.Items.Add("--Select one--")
        While i <= subj
            Me.dl_sub.Items.Add(ds.Tables("fs").Rows(i).Item("subj_name").ToString)
            i = i + 1
        End While
    End Sub
    'reterive ques from database
    Public Sub getques()
        Dim lstitem As New System.Web.UI.WebControls.ListItem
        cm = New SqlCommand("select * from ques_mst order by ques_id", con)
        da = New SqlDataAdapter(cm)
        ds = New DataSet
        da.Fill(ds, "ques")
        If ds.Tables("ques").Rows.Count > 0 Then
            i = ds.Tables("ques").Rows.Count - 1
            c = 0
            While c <= i
                lstitem = New System.Web.UI.WebControls.ListItem
                lstitem.Text = "Q " & ds.Tables("ques").Rows(c).Item("ques_id").ToString
                lstitem.Value = ds.Tables("ques").Rows(c).Item("ques_id").ToString
                Me.rbl_ques.Items.Add(lstitem)
                c = c + 1
            End While
        End If
        If dg_ques.Rows.Count = 0 Then
            Me.dg_ques.DataSource = ds.Tables("ques")
            Me.dg_ques.DataBind()
 
        End If
        i = 0
    End Sub
 
    'reterive option and ques_txt from database
    Protected Sub rbl_ques_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        cm = New SqlCommand("SELECT q.ques_id,q.ques_txt, o.option_id,o.option_txt FROM ques_mst q INNER JOIN option_mst o ON q.ques_id = o.ques_id where q.ques_id='" & Me.rbl_ques.SelectedValue.ToString & "'order by o.option_id", con)
        da = New SqlDataAdapter(cm)
        ds = New DataSet
        da.Fill(ds, "q1")
        rbl_op.Items.Clear()
        If ds.Tables("q1").Rows.Count > 0 Then
            Me.l_ques.Text = "Q. " + ds.Tables("q1").Rows(0).Item("ques_txt").ToString
            While i <= ds.Tables("q1").Rows.Count - 1
                Me.rbl_op.Items.Add(ds.Tables("q1").Rows(i).Item("option_txt").ToString)
                i = i + 1
            End While
        End If
        i = 0
    End Sub
    'checking existing subj from table
    Protected Sub b_feedback_Click(ByVal sender As Object, ByVal e As System.EventArgs)
 
        cm = New SqlCommand("select * from feedback_detail_mst where subj_name='" & Me.dl_sub.SelectedItem.ToString & "'", con)
        da = New SqlDataAdapter(cm)
        ds = New DataSet
        da.Fill(ds, "s2")
        If ds.Tables("s2").Rows.Count > 0 Then
            MsgBox("already attempted")
        Else
            p_ques.Visible = True
            p_sub.Visible = False
        End If
        
    End Sub
    'saveing data into gridview 
    Protected Sub b_save_Click(ByVal sender As Object, ByVal e As System.EventArgs)
 

        i = dg_ques.Rows.Count
        c = 0
        While c < i
            If Me.dg_ques.Rows(c).Cells(0).Text = Me.rbl_ques.Text.ToString Or Me.rbl_op.SelectedIndex = -1 Then
                MsgBox("Value Already Exists/Not Select Any Option", MsgBoxStyle.Critical, "Appraisal")
                Exit While
            End If
            If dg_ques.Rows(c).Cells(0).Text.ToString = "" Then
                Me.dg_ques.Rows(c).Cells(0).Text = Me.rbl_ques.Text
                Me.dg_ques.Rows(c).Cells(1).Text = (Me.rbl_op.SelectedIndex + 1).ToString
                Me.dg_ques.Rows(c).Cells(2).Text = "Y"
                Exit While
            End If
            c = c + 1
        End While
        If i = c + 1 Then
            Me.b_submit.Visible = True
            Me.b_save.Visible = False
        End If
        Me.dg_ques.Visible = True
        i = 0
    End Sub
    Protected Sub b_submit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        p_sub.Visible = True
        p_ques.Visible = False
        insertdata()
 
       
        Me.b_submit.Visible = False
        Me.b_save.Visible = True
 

    End Sub
    'reteriving option value from database
    Public Sub getoptionval()
        cm = New SqlCommand("select option_val from option_mst where option_txt='" & Me.rbl_op.SelectedItem.ToString & "'", con)
        da = New SqlDataAdapter(cm)
        ds = New DataSet
        da.Fill(ds, "op")
        If ds.Tables("op").Rows.Count > 0 Then
            op = ds.Tables("op").Rows(0).Item("option_val").ToString
        End If
    End Sub
    'fetching transaction id from table
    Public Sub gettransid()
        cm = New SqlCommand("select trans_id from series_gen_mst", con)
        da = New SqlDataAdapter(cm)
        ds = New DataSet
        da.Fill(ds, "tid")
        If ds.Tables("tid").Rows.Count > 0 Then
            trans = ds.Tables("tid").Rows(0).Item("trans_id").ToString
        End If
    End Sub
    'insert data into database table& updatae trans id
    Public Sub insertdata()
        gettransid()
        cr = Session("course").ToString
        b1 = Session("branch").ToString
        b2 = Session("batch").ToString
        s1 = Session("sem").ToString
        While i <= Me.dg_ques.Rows.Count - 1
 

            cm = New SqlCommand("select option_val from option_mst where ques_id='" & Me.dg_ques.Rows(i).Cells(0).Text & "'and option_id='" & Me.dg_ques.Rows(i).Cells(1).Text & "'", con)
            da = New SqlDataAdapter(cm)
            ds = New DataSet
            da.Fill(ds, "op")
            If ds.Tables("op").Rows.Count > 0 Then
                op = ds.Tables("op").Rows(0).Item("option_val").ToString
            End If
            cm = New SqlCommand("INSERT INTO feedback_detail_mst(trans_id,ques_id,option_id, option_val, course_name, branch_name, batch_name, sem_dcd, faculty_name, subj_name)values('" & trans & "','" & Me.dg_ques.Rows(i).Cells(0).Text & "','" & Me.dg_ques.Rows(i).Cells(1).Text & "','" & op.ToString & "','" & cr.ToString & "','" & b1.ToString & "','" & b2.ToString & "','" & s1.ToString & "','" & Me.tb_fname.Text & "','" & Me.tb_sname.Text & "')", con)
            cm.ExecuteNonQuery()
            i = i + 1
        End While
        cm = New SqlCommand("update series_gen_mst set trans_id='" & trans + 1 & "'", con)
        cm.ExecuteNonQuery()
        i = 0
    End Sub
    'retriving faculty & subj name from database table
    Protected Sub dl_sub_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        cm = New SqlCommand("SELECT e.EmpName, s.subj_name FROM faculty_subject_link_mst f INNER JOIN subj_mst s ON f.subjcd = s.subjcd INNER JOIN V_EmpMstDtl e ON f.emp_id = e.EmpId WHERE s.subj_name ='" & Me.dl_sub.SelectedItem.ToString & "'", con)
        da = New SqlDataAdapter(cm)
        ds = New DataSet
        da.Fill(ds, "fs")
        If ds.Tables("fs").Rows.Count > 0 Then
            Me.tb_fname.Text = ds.Tables("fs").Rows(0).Item("empname").ToString
            Me.tb_sname.Text = ds.Tables("fs").Rows(0).Item("subj_name").ToString
        End If
        
    End Sub
    Protected Sub b_exit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        cm = New SqlCommand("SELECT COUNT (trans_id )AS  tid FROM feedback_detail_mst", con)
        da = New SqlDataAdapter(cm)
        ds = New DataSet
        da.Fill(ds, "t1")
        If ds.Tables("t1").Rows.Count > 0 Then
            i = ds.Tables("t1").Rows(0).Item("tid").ToString
        End If
    End Sub
    'Public Sub ref()
    '    me.
    'End Sub
End Class
 

 
and here is my html code
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="studfeedback.aspx.vb" Inherits="_Default" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table style="text-align: center">
        <tr>
            <td style="width: 100px; height: 21px; text-align: center;" align="center">
                <br />
                <asp:Panel id="p_sub" runat="server" Height="50px" Width="125px">
                    <table style="text-align: center">
                        <tr>
                            <td style="width: 125px; height: 24px;">
                                <asp:Label id="l_sub" runat="server" Text="Choose Your Subject Name" Width="252px" Height="24px"></asp:Label></td>
                            <td style="width: 16575px; height: 24px;">
                                &nbsp;<asp:DropDownList id="dl_sub" runat="server" AutoPostBack="True" Width="190px" OnSelectedIndexChanged="dl_sub_SelectedIndexChanged" >
                                <asp:ListItem Text ="---Selectone--"></asp:ListItem></asp:DropDownList></td>
                        </tr>
                        <tr style ="width :auto ">
                            <td colspan="2" style="height : 100px; text-align: left;"><span style="font-weight: bold" >
                            1. choose the subject from the list&nbsp;<br />
                                2. click on the button to give you feedback&nbsp;<br />
                            3. choose the question from quesId&nbsp;<br />
                            4. click on the save button to save your feedback&nbsp;<br />
                            5.click on the submit button to submit your feedback&nbsp;<br />
                            6. click on next button to choose your next subject&nbsp;<br />
                                7. click on exit button when you complete your feedback</span>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" style="height: 26px">
                                <asp:Button id="b_feedback" runat="server" Text="Give Your Feedback" OnClick="b_feedback_Click" />
                                &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
                                <asp:Button ID="b_exit" runat="server" OnClick="b_exit_Click" Text="Exit" Visible="False"
                                    Width="153px" /></td>
                        </tr>
                    </table>
                </asp:Panel>
                &nbsp; &nbsp;</td>
        </tr>
        <tr>
            <td style="width: 100px; height: 348px;">
                <asp:Panel id="p_ques" runat="server" Height="50px" Width="125px" Visible="False">
                    <table style="height: 289px">
                        <tr>
                            <td align="center" style="width: 100px; height: 11px">
                                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;
                                &nbsp; &nbsp;
                                <asp:Label id="l_fname" runat="server" Height="25px" Text="Faculty Name" Width="98px">
                                </asp:Label></td>
                            <td align="center" style="width: 100px; height: 11px">
                                <asp:TextBox id="tb_fname" runat="server" ReadOnly="True">
                                </asp:TextBox></td>
                            <td align="center" style="width: 100px; height: 11px">
                                <asp:Label id="l_sname" runat="server" Text="Subject Name" Width="151px" Height="27px"></asp:Label></td>
                            <td align="center" style="width: 100px; height: 11px">
                                <asp:TextBox id="tb_sname" runat="server" ReadOnly="True">
                                </asp:TextBox></td>
                        </tr>
                        <tr>
                            <td colspan="4" style="height: 21px">
                                <table cellpadding="2" cellspacing="5">
                                    <tr>
                                        <td rowspan="2" style="width: 120px; height: 146px">
                                            <asp:Label id="l_qid" runat="server" Font-Bold="True" Text="QUES ID" Width="109px"></asp:Label>
                                            <asp:RadioButtonList id="rbl_ques" runat="server" AutoPostBack="True" BackColor="#E0E0E0"
                                                BorderColor="#E0E0E0" BorderStyle="Ridge" OnSelectedIndexChanged="rbl_ques_SelectedIndexChanged"
                                                Width="80px">
                                            </asp:RadioButtonList></td>
                                        <td style="width: 100px; height: 146px">
 
                                                <table>
                                                    <tr>
                                                        <td colspan="2" style="width: 529px; height: 21px; text-align: left;">
                                                            <asp:Label id="l_ques" runat="server" Width="376px"></asp:Label></td>
                                                    </tr>
                                                    <tr>
                                                        <td colspan="4" style="height: 47px; text-align: left" align="right">
                                                            <asp:RadioButtonList ID="rbl_op" runat="server" >
                                                              </asp:RadioButtonList>&nbsp;
                                                    <tr>
                                                        <td colspan="4" style="height: 26px">
                                                            <asp:Button id="b_save" runat="server" Text="Save Record" OnClick="b_save_Click" />
                                                            <asp:Button id="b_submit" runat="server" Text="Submit Record" OnClick="b_submit_Click" Visible="False" />
                                                            </td>
                                                    </tr>
                                                </table>
 
                                        </td>
                                        <td style="width: 100px; height: 146px">
                                            <asp:GridView id="dg_ques" runat="server" AutoGenerateColumns="False" Height="153px"
                                                Visible="False" Width="182px">
                                                <columns>
<asp:BoundField HeaderText="QuesId"></asp:BoundField>
<asp:TemplateField HeaderText="Selected Option"></asp:TemplateField>
<asp:TemplateField HeaderText="Question Attempted"></asp:TemplateField>
</columns>
                                            </asp:GridView></td>
                                    </tr>
                                </table>
                                &nbsp;</td>
                            <div>
                            </div>
                        </tr>
                    </table>
                </asp:Panel></td>
        </tr>
    </table>
</asp:Content>
Posted 28-Feb-13 0:40am
Edited 28-Feb-13 0:44am
(no name)2.4K
v2

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

  Print Answers RSS
0 OriginalGriff 200
1 George Jonsson 175
2 Kornfeld Eliyahu Peter 169
3 PIEBALDconsult 110
4 Richard MacCutchan 85
0 OriginalGriff 6,080
1 DamithSL 4,648
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,624
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 28 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100