Hi Phil,
Based on my understanding, I understand that you want the checkboxs align in the same line. For example:
| Edit | id1 | chk1 chk2 chk3 ?. |
| Edit | id2 | chk1 chk2 chk3 ?. |
?
For this scenario, please refer to the following link:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Edit</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:TemplateField HeaderText="CheckBoxs">
<ItemTemplate>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
<asp:Label ID="Label1" runat="server" Style="display: none" Text='<%# Eval("CheckBoxs")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
********** code behind
Private myTable As DataTable
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
myTable = New DataTable()
myTable.Columns.Add("ID", GetType(Int32))
myTable.Columns.Add("CheckBoxs", GetType(String))
myTable.Rows.Add(1, "true_false_true")
myTable.Rows.Add(2, "false_false_false")
myTable.Rows.Add(3, "true_false_false")
GridView1.DataSource = myTable
GridView1.DataBind()
End Sub
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim ph As PlaceHolder = DirectCast(e.Row.Cells(2).FindControl("PlaceHolder1"), PlaceHolder)
Dim label1 As System.Web.UI.WebControls.Label = DirectCast(e.Row.Cells(2).FindControl("Label1"), System.Web.UI.WebControls.Label)
Dim checkboxarray As String() = label1.Text.Split("_"c)
For i As Integer = 0 To checkboxarray.Length - 1
Dim cb As New System.Web.UI.WebControls.CheckBox()
cb.Checked = checkboxarray(i).Equals("true")
cb.Text = checkboxarray(i)
ph.Controls.Add(cb)
Next
End If
End Sub
Protected Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Response.Redirect("Edit.aspx")
End Sub
Sincerely,
Benson Yu
Microsoft Online Community Support
Please remember to click ?Mark as Answer? on the post that helps you, and to click ?Unmark as Answer? if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.