Click here to Skip to main content
15,910,877 members
Home / Discussions / ASP.NET
   

ASP.NET

 
Questiona gridview without any datasource Pin
sayonifahim7-Nov-07 21:54
sayonifahim7-Nov-07 21:54 
AnswerRe: a gridview without any datasource Pin
N a v a n e e t h7-Nov-07 22:17
N a v a n e e t h7-Nov-07 22:17 
AnswerRe: a gridview without any datasource Pin
M_Menon8-Nov-07 1:58
M_Menon8-Nov-07 1:58 
AnswerRe: a gridview without any datasource Pin
surer8-Nov-07 4:10
surer8-Nov-07 4:10 
Questionhow to perform click event on dynamically created bottons Pin
yogesh_softworld1237-Nov-07 20:45
yogesh_softworld1237-Nov-07 20:45 
AnswerRe: how to perform click event on dynamically created bottons Pin
Guffa7-Nov-07 20:48
Guffa7-Nov-07 20:48 
AnswerRe: how to perform click event on dynamically created bottons Pin
Christian Graus7-Nov-07 22:31
protectorChristian Graus7-Nov-07 22:31 
QuestionHi clear my doubt....plz Pin
Thanigaimani837-Nov-07 20:14
Thanigaimani837-Nov-07 20:14 
Hi guys.
i can explain for my doubt with example.see.my table have multiple type of employee details like as Mangemment,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 Mangemment type of employee grid view showing that type of employee details ,here i checked first two employee details then checkbox values put in one viewstate,then i go to Programmer type of employee it showing that type employee details here i want to checked two employee details using checkbox but what happened first two checkboxes are already checked. so view state having proper checked check box values but problem is
whenever i go to select for another type of employee details checkboxes are checked based upon order of previous checked index.
i checked checkbox values of dropdown list selected index changed event,values are coming from viewstate,so we want viewstate values add plus new checked checkbox values ,but if i click display button control that viewstate values are removing then new checked checkbox values are only diaplay .

see my code behind..

i can put tears smile near code where i used viewstate and i can qustioned smile near the code of viewstate values are removing( i mean previous page checked checkbox values).




Protected Sub gridview1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles gridview1.PageIndexChanging

gridview1.PageIndex = e.NewPageIndex

getselected()

databind1("First_name", "asc")

setSelected()


End Sub

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

Public Sub getselected()



Dim arrayListContactGroup As New ArrayList


Cry | :(( If ViewState("ArrayList") IsNot Nothing Then

arrayListContactGroup = CType(ViewState("ArrayList"), ArrayList)

ViewState.Remove("ArrayList")



End If

For 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

Confused | :confused: arrayListContactGroup.Remove(arraylistlabel.Text)


End If



End If



Next

ViewState("ArrayList") = arrayListContactGroup

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

Public Sub setSelected()



Dim arrayListContactGroup As New ArrayList


Cry | :((
If ViewState("ArrayList") IsNot Nothing Then
arrayListContactGroup = CType(ViewState("ArrayList"), ArrayList)


End If

For 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

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


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

getselected()

databind1(ViewState("sort"), ViewState("ascdesc"))

setSelected()



End Sub

My problem is,arraylist values(checkbox values) stored in viewstate,viewstate get the values no problem,but whenever i go to dropdown list select index change at that time we want add viewstate values and current checked checkbox values,but its doing opposite side operation i mean removing the view state value.see i can underlined that line.






Thanigaimani.thirumalai

AnswerRe: Display The roles Pin
N a v a n e e t h7-Nov-07 21:38
N a v a n e e t h7-Nov-07 21:38 
GeneralDisplay The roles Pin
SreejithAchutan7-Nov-07 21:55
SreejithAchutan7-Nov-07 21:55 
GeneralRe: Display The roles Pin
N a v a n e e t h7-Nov-07 22:12
N a v a n e e t h7-Nov-07 22:12 
GeneralDisplay The roles Pin
SreejithAchutan7-Nov-07 22:24
SreejithAchutan7-Nov-07 22:24 
GeneralRe: Display The roles Pin
Christian Graus7-Nov-07 22:47
protectorChristian Graus7-Nov-07 22:47 
QuestionAuto Complete TextBox Pin
kirthikirthi7-Nov-07 20:01
kirthikirthi7-Nov-07 20:01 
AnswerRe: Auto Complete TextBox Pin
N a v a n e e t h7-Nov-07 21:39
N a v a n e e t h7-Nov-07 21:39 
GeneralRe: Auto Complete TextBox Pin
kirthikirthi7-Nov-07 23:01
kirthikirthi7-Nov-07 23:01 
GeneralRe: Auto Complete TextBox Pin
N a v a n e e t h7-Nov-07 23:18
N a v a n e e t h7-Nov-07 23:18 
QuestionDeveloping Crystal Reports using IIlist Pin
dandamudi padma7-Nov-07 19:55
dandamudi padma7-Nov-07 19:55 
AnswerRe: Developing Crystal Reports using IIlist Pin
N a v a n e e t h7-Nov-07 21:40
N a v a n e e t h7-Nov-07 21:40 
GeneralRe: Developing Crystal Reports using IIlist Pin
dandamudi padma7-Nov-07 22:02
dandamudi padma7-Nov-07 22:02 
GeneralRe: Developing Crystal Reports using IIlist Pin
N a v a n e e t h7-Nov-07 22:14
N a v a n e e t h7-Nov-07 22:14 
QuestionCompare Validator Problem Pin
Jintal Patel7-Nov-07 19:44
Jintal Patel7-Nov-07 19:44 
AnswerRe: Compare Validator Problem Pin
aswini7-Nov-07 20:28
aswini7-Nov-07 20:28 
AnswerRe: Compare Validator Problem Pin
Krushna Sahu7-Nov-07 20:31
Krushna Sahu7-Nov-07 20:31 
QuestionDifference betwen single tier and N tier application. Pin
rahul.net117-Nov-07 19:30
rahul.net117-Nov-07 19:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.