Register  |  Login




Advertisement

Start Your Own Q&A Site

Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.

Question

Status: Open Points: 75 Time: 08:50 - Nov 19, 2007  

thanigaimani83

I need ur help.plz

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=javascr

Answer Discussion
Tutorials

 

This question has not yet been answered.

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

Tutorials cannot be submitted until the Answer Discussion is complete.

Submit answers in the Answer Discussion area

Ask a Question

Have a new question? Ask!

You have 100 characters to use



Top Experts

View More

Rank

Expert

Points

1.

nidhi

10354

2.

oracleofDelphi

6493

3.

rcastagna

5596

4.

LAGM

4848

5.

PeterNZ

3487

6.

gonzalo

2840

7.

Mason

2770

8.

jgivoni

2303

9.

xarcus

1820

10.

Anpanman

917

Become an Expert

Register today to share your knowledge with the community and be recognized and rewarded for your contributions.


Register Here




"Psst, Quomon is a great site. Pass it on."     Tell a Friend  |   Link To Us  |   Save to Delicious  |   Digg! Digg it



Language Options

English:

www.quomon.com

Español:

www.quomon.es