Foor loop Code Block in ASPX Page
-
Hi guys, I got little problem here. I cannot get the value for ColName. Below are my code
<tr ondblclick="job_detail('<%#Eval("id")%>');" >
<td width="15"><input name="Checkbox51" type="checkbox" style=" width:13px; height:13px;" value="<%#Eval("id")%>" /></td>
<%
For j = 0 To countCol - 1
Response.Write("<td width=" & colSize(j) & ">" & Eval(colName(j)) & "</td>")
Next
%>
</tr>It give me an error : Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control. Can someone help me. Thanks in advance. matju
ma
tju
Software Application Engineer Petaling Jaya,Selangor, Malaysia Ring Master SB MVP 2008 ;p Petaling Jaya MOP (Otai) -
Hi guys, I got little problem here. I cannot get the value for ColName. Below are my code
<tr ondblclick="job_detail('<%#Eval("id")%>');" >
<td width="15"><input name="Checkbox51" type="checkbox" style=" width:13px; height:13px;" value="<%#Eval("id")%>" /></td>
<%
For j = 0 To countCol - 1
Response.Write("<td width=" & colSize(j) & ">" & Eval(colName(j)) & "</td>")
Next
%>
</tr>It give me an error : Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control. Can someone help me. Thanks in advance. matju
ma
tju
Software Application Engineer Petaling Jaya,Selangor, Malaysia Ring Master SB MVP 2008 ;p Petaling Jaya MOP (Otai)hi, Just remove eval from Response.Write("<td width=" & colSize(j) & ">" & colName(j) & "</td>") this line. Hope it 'll help u Thanks
-
hi, Just remove eval from Response.Write("<td width=" & colSize(j) & ">" & colName(j) & "</td>") this line. Hope it 'll help u Thanks
-
Hi, Actually i need to use Eval to bind the data from datasource. But to use eval I need to include the '#' sign.
ma
tju
Software Application Engineer Petaling Jaya,Selangor, Malaysia Ring Master SB MVP 2008 ;p Petaling Jaya MOP (Otai)can you put the code that how you bind the datasource?
Regards Keyur Satyadev
-
can you put the code that how you bind the datasource?
Regards Keyur Satyadev
Sure, here is the code.
Dim conn As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings(0).ConnectionString) Dim sqlDA As New SqlDataAdapter("SELECT id, filename, img\_size FROM image ORDER BY id", conn) Dim ds As New DataSet Dim pgDataSrc As New PagedDataSource Try sqlDA.Fill(ds, "tl") pgDataSrc.DataSource = ds.Tables("tl").DefaultView pgDataSrc.AllowPaging = True pgDataSrc.PageSize = 20 pgDataSrc.CurrentPageIndex = CurrentPage 'rptInbox is a repeater control rptInbox.DataSource = pgDataSrc rptInbox.DataBind() Catch ex As Exception Return False Finally conn = Nothing sqlDA = Nothing ds = Nothing End Try
Well sometimes user want to see just 1 or more column in the repeater. Thats why i use for loop to generate the column. Hope this help. Thanks in advance.
ma
tju
Software Application Engineer Petaling Jaya,Selangor, Malaysia Ring Master SB MVP 2008 ;p Petaling Jaya MOP (Otai) -
Sure, here is the code.
Dim conn As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings(0).ConnectionString) Dim sqlDA As New SqlDataAdapter("SELECT id, filename, img\_size FROM image ORDER BY id", conn) Dim ds As New DataSet Dim pgDataSrc As New PagedDataSource Try sqlDA.Fill(ds, "tl") pgDataSrc.DataSource = ds.Tables("tl").DefaultView pgDataSrc.AllowPaging = True pgDataSrc.PageSize = 20 pgDataSrc.CurrentPageIndex = CurrentPage 'rptInbox is a repeater control rptInbox.DataSource = pgDataSrc rptInbox.DataBind() Catch ex As Exception Return False Finally conn = Nothing sqlDA = Nothing ds = Nothing End Try
Well sometimes user want to see just 1 or more column in the repeater. Thats why i use for loop to generate the column. Hope this help. Thanks in advance.
ma
tju
Software Application Engineer Petaling Jaya,Selangor, Malaysia Ring Master SB MVP 2008 ;p Petaling Jaya MOP (Otai)why should you write the response.write here as bind function only work with control. you can use just Databinder.Eval() or simply Eval() as it your repeater control you get all the values. for more specify your exact need to writing the response.write as its just give the message.
Regards Keyur Satyadev
-
why should you write the response.write here as bind function only work with control. you can use just Databinder.Eval() or simply Eval() as it your repeater control you get all the values. for more specify your exact need to writing the response.write as its just give the message.
Regards Keyur Satyadev
Actually I try to do this:
<%
For j = 0 To countCol - 1
'during loop it will skip this line. This is why I use response.write.
<td width=<%#(colSize(j))%>><%#Eval(colName(j))%></td>
Next
%>but when it loops it will skip the code in the for loop. When i use response.write it will run line in for loop but return this error: Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control. Hope this help. Thanks in advanced.
ma
tju
Software Application Engineer Petaling Jaya,Selangor, Malaysia Ring Master SB MVP 2008 ;p Petaling Jaya MOP (Otai) -
Actually I try to do this:
<%
For j = 0 To countCol - 1
'during loop it will skip this line. This is why I use response.write.
<td width=<%#(colSize(j))%>><%#Eval(colName(j))%></td>
Next
%>but when it loops it will skip the code in the for loop. When i use response.write it will run line in for loop but return this error: Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control. Hope this help. Thanks in advanced.
ma
tju
Software Application Engineer Petaling Jaya,Selangor, Malaysia Ring Master SB MVP 2008 ;p Petaling Jaya MOP (Otai)why you put the for loop as it is in the repeater. repeater will automatically manage this. it will returns for all the rows. can you more specify your exact requirement as what type of data you want to bind here?
Regards Keyur Satyadev