|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
how to display records in datagridi want to display records in datagrid. strtestids() is a string array. it contains some testids. based on these ids i've to fill the datagrid. i wrote code like this Dim db As New NESDK.DatabaseGrid Dim i As Integer For i = 0 To strTestIds.Length - 1 If db.Run("select Testname,TestId,NoOfQues,TotalTime from TestInfo where testid='" & strTestIds(i) & "'") Then grdTests.DataSource = db.Result grdTests.DataBind() End If Next here in grid am getting only the last record. i.e if my string array contains 2 records in grid am getting last record instead of 2 records. can any one tell me how to do this one. why am getting last record only? Thanx in advance Yoshitha Yoshitha,
The code snippet you've provided calls the databind() method on each iteration of the loop, effectively refreshing the datasource. You might try changing your query to find a result set with all records that have id's in your specified range. Example: Dim db As New NESDK.DatabaseGrid 'Some datagrid Dim i As Integer Dim strQuery as String 'Build Query strQuery = "SELECT Testname,TestId,NoOfQues,TotalTime FROM TestInfo WHERE testid IN (" 'Build IN (Values) For i = 0 To strTestIds.Length - 1 strQuery = strQuery & "'" & strTestIds(i) & "'," Next 'Remove last comma strQuery = strQuery.Remove(strQuery.Length-1,1) 'Put strQuery together strQuery = strQuery + ")" 'Execute your databinding code If db.Run(strQuery) Then grdTests.DataSource = db.Result grdTests.DataBind() End If Ryan Show quoteHide quote "yoshitha" wrote: > hi, > > i want to display records in datagrid. > > strtestids() is a string array. > > it contains some testids. > > based on these ids i've to fill the datagrid. > > i wrote code like this > > Dim db As New NESDK.DatabaseGrid > > > Dim i As Integer > > For i = 0 To strTestIds.Length - 1 > > > If db.Run("select Testname,TestId,NoOfQues,TotalTime from > > TestInfo where testid='" & strTestIds(i) & "'") Then > grdTests.DataSource = db.Result > grdTests.DataBind() > End If > Next > > > here in grid am getting only the last record. i.e if my string array > > contains 2 records in grid am getting last record instead of 2 records. > > can any one tell me how to do this one. why am getting last record only? > > Thanx in advance > Yoshitha > > >
Customizing ASP.NEt Hyperlink Control
How to validate one of two Required TextBox Need Click Event to Fire from TextBox Defining server-side Click event for Label web contol ? Urgent! GridView and templated controls binding---------Plz help TemplateControl?? Creating a Tab in web form Windows Explorer style custom control for web Textboxes with images make a button deault |
|||||||||||||||||||||||