User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 455,964 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,630 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 1213 | Replies: 1
Reply
Join Date: Nov 2007
Posts: 2
Reputation: thanigaimani83 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
thanigaimani83 thanigaimani83 is offline Offline
Newbie Poster

Question Hi guys please clear my doubt.

  #1  
Nov 19th, 2007
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2003
Location: Nashville, TN
Posts: 2,333
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Rep Power: 11
Solved Threads: 102
Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: Hi guys please clear my doubt.

  #2  
Dec 7th, 2007
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...
Alex Cavnar, aka alc6379
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 9:03 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC