Hi Rifky,

The string builder isn't creating server controls for rendering, you
are just creating a string that happens to contain the syntax of a
server control.  The key difference being the string will never be
executed by the server, rather just dumped out to the user.

I bet if you viewed your HTML source of the page, you'll see
<asp:linkbutton...." in your markup


What you'd want to do instead is create instances of the HtmlTable
class (http://msdn.microsoft.com/en-us/library/
system.web.ui.htmlcontrols.htmltable(v=vs.80).aspx)  and add the
control programatically.

Somthing like
Dim tbl as HTMLTable
Dim tr as HTMLTableRow
Dim td as HTMLTabelCell
Dim lnkbtn as linkbutton

(do your stuff to each control)

Then something like
td.Controls.Add(lnkbtn)
tr.Controls.Add(td)
tbl.controls.add(tr)


Finally add the tbl control to your panel that is part of the page.




On Jan 27, 6:10 am, Rifky Rafeethu <[email protected]> wrote:
> Dear All,
>
> i'm triying to create a table in the code behind file by reading the
> database using datareader. and add the string to Div Tags InnerHTM part to
> show it in the ASPX page. the table details are appearing properly. my
> problem is, in the first column i'm adding a linkButton to make the user
> click to call a method in the code behind file.
>
> but the link button is not appearing in all the rows.
>
> i have added the coding below.. the output also attached as a image..
>
> the first column is empty in all the cells..
>
> what am i missing here.. please help.
>
> Dim sb As New StringBuilder
>
> sb.Append("")
>
>             sb.Append("<table class='sGrid' width='510px'>")
>             sb.Append("<tr>")
>             sb.Append("<th scope='col' style='width: 40px;'>&nbsp;</th>")
>             sb.Append("<th scope='col' style='width: 70px;' align='left'>PO
> No.</th>")
>             sb.Append("<th scope='col' style='width: 25px;'
> align='left'>Ver</th>")
>             sb.Append("<th scope='col' style='width: 70px;'
> align='left'>Date</th>")
>             sb.Append("<th scope='col' style='width: 80px;'
> align='left'>Type</th>")
>             sb.Append("<th scope='col' style='width: 50px;'
> align='left'>Country</th>")
>             sb.Append("<th scope='col' style='width: 80px;'
> align='left'>Handling User</th>")
>             sb.Append("</tr>")
>
>             While dr.Read
>                 sb.Append("<tr>")
>                 sb.Append("<td><asp:LinkButton ID='lnk" &
> dr("PONo").ToString & "' runat='server' CommandName='" & dr("PONo").ToString
> & "' CommandArgument='" & dr("VersionNo").ToString & "'
> OnCommand='LoadPOSummaryTrigger' Text='Select'/></td>")
>                 sb.Append("<td>" & dr("PONo").ToString & "</td>")
>                 sb.Append("<td>" & dr("VersionNo").ToString & "</td>")
>                 sb.Append("<td>" & Format(CDate(dr("PODate")),
> "dd-MMM-yyyy") & "</td>")
>                 sb.Append("<td>" & dr("ProductType").ToString & "</td>")
>                 sb.Append("<td>" & dr("CountryOfOrigin").ToString & "</td>")
>                 sb.Append("<td>" & dr("UserName").ToString & "</td>")
>                 sb.Append("</tr>")
>             End While
>
>  sb.Append("</table>")
>
> divCordList.InnerHtml = sb.ToString
>
> Rgds
> Rifky
>
>  table.JPG
> 20KViewDownload

Reply via email to