944,205 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 2045
  • ASP.NET RSS
Nov 19th, 2007
0

Hi guys please clear my doubt.

Expand Post »
Hi guys.

i can explain for my doubt with example.see.my table have multiple type of employee details like as Managmment,Programmer,Designers,Accountants,Contra ctEmployees.Each type of department having many employee details.Now my drop down list having types of department names like that above types of department names..if i select any one type of department data wil be display in gridview format .gridview data column as employee Name,Address,Phone_No,email_address and each every row with checkboxes.gridview showing data according to select the dept.No problem. first I select Managmment type of employee grid view showing that type of employee details ,here i checked first two employee details then i go to Programmer type of employee it showing that type employee details here i want to checked two employee details using checkbox after then i click button control,so we want two plus two, four employee details values..getting values i putting in arraylist then i puttong one view state.

If we are not select dropdown list index change selecting checkbox values are getting proper. but problem is whenever i go to select dropdown list index change i mean page post back previous checked checkbox values are getting improper.

This one viewstate problem or dropdown list or gridview problem

I used arraylist stored in session state also. But no one improvement.

see my code behind..whats problem in here code tell me..

--------dropdown list selected change event--------------------------



Protected Sub Selcon_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Selcon.SelectedIndexChanged getselected()databind1 ()

setSelected()


End Sub

--------------Getting the checkbox values from gridview then put in session state-------------------

Public Sub getselected()



Dim arrayListContactGroup As New ArrayList



If Session("ArrayList") IsNot Nothing ThenarrayListContactGroup = CType(Session("ArrayList"), ArrayList)

Session.Remove(

"ArrayList")



End IfFor Each row As GridViewRow In gridview1.Rows



Dim chkselectcontacts As CheckBox = CType(row.FindControl("chksel"), CheckBox)Dim arraylistlabel As Label = CType(row.FindControl("contid"), Label)



If chkselectcontacts.Checked Then



If Not arrayListContactGroup.Contains(arraylistlabel.Text) Then

arrayListContactGroup.Add(arraylistlabel.Text)


End If



Else



If arrayListContactGroup.Contains(arraylistlabel.Text) Then

arrayListContactGroup.Remove(arraylistlabel.Text)


End If



End If



NextSession("ArrayList") = arrayListContactGroup



End Sub

-----------------checking the checkboxes are checked or unchecked from session state -----------------

Public Sub setSelected()



Dim arrayListContactGroup As New ArrayList



If Session("ArrayList") IsNot Nothing ThenarrayListContactGroup = CType(Session("ArrayList"), ArrayList)



End IfFor Each row As GridViewRow In gridview1.Rows



Dim chkselectcontacts As CheckBox = CType(row.FindControl("chksel"), CheckBox)Dim arraylistlabel As Label = CType(row.FindControl("contid"), Label)



If arrayListContactGroup.Contains(arraylistlabel.Text) Then

chkselectcontacts.Checked =

True



Else

chkselectcontacts.Checked =

False



End If



Next



End Sub

---------Final stage checkbox values are submitting to the button control-------------

Protected Sub btnsel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsel.Click getselected()

contactsselected()


End Sub

-------------checkbox values are passed to database then retrieve to requering field data .i wrote one function in Button control ---------------

Public Sub contactsselected()



Dim arrayListContactGroup As New ArrayList



If Session("ArrayList") IsNot Nothing ThenarrayListContactGroup = CType(ViewState("ArrayList"), ArrayList)



End If



If arrayListContactGroup.Count = 0 ThenResponse.Write(" <script language=javascript> alert('Please select atleast one contact') </script>")



Exit Sub



ElseFor Count As Integer = 0 To arrayListContactGroup.Count - 1

arraystringcontact += arrayListContactGroup(Count).ToString +

","



Next



arraystringcontact = arraystringcontact.Substring(0, arraystringcontact.LastIndexOf(","))

ds = objclient.contactsRetriveToDiary(Request.Cookies(

"Master")("AgentId"), Request.Cookies("Master")("BrokerId"), arraystringcontact)

constring =

"<div id='divid'><table>"For i As Integer = 0 To ds.Tables(0).Rows.Count - 1

constring = constring &

"<tr><td>" & "</td><td>" & ds.Tables(0).Rows(i).Item("Name").ToString & "</td><td>" & ds.Tables(0).Rows(i).Item("Address").ToString & "</td><td>" & ds.Tables(0).Rows(i).Item("Phone").ToString & "</td><td>" & ds.Tables(0).Rows(i).Item("email").ToString & "</td></tr>" & "<br>"



Next

constring = constring &

"</table></div>"

divcontact.InnerHtml = constring


End IfSession("KK") = arraystringcontact



End Sub

--------------------

whats problems in my code,whenever i change dropdown selected index change getselected function not getting proper selected checkbox values ...

reply me
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
thanigaimani83 is offline Offline
2 posts
since Nov 2007
Dec 7th, 2007
0

Re: Hi guys please clear my doubt.

Can you please modify your post to include [code] tags? Additionally, I am not entirely sure if I understand what the code is supposed to be doing, versus what it is doing.

Also, there is a WHOLE lot of whitespace in your code. I don't know if the forum did that, but it really makes things that much harder to read...
Team Colleague
Reputation Points: 186
Solved Threads: 147
Cookie... That's it
alc6379 is offline Offline
2,519 posts
since Dec 2003

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: GidView RowDataBound Problem...
Next Thread in ASP.NET Forum Timeline: RowDelelting Event





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC