Results 1 to 6 of 6

Thread: Datagrid & Checkboxs [Resolved]

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    43

    Resolved Datagrid & Checkboxs [Resolved]

    Hello, this is what I want to do...
    I'have got a value in my database that can be true or false, en when I read out my table into a datagrid, I want a checkbox that is checked when the value is true and unchecked when it is false.

    First it was a pain just getting the checkbox in the datagrid, but I got this solved by using a template Column.

    But I realy haven't got a clue how to preset the checkbox ....


    My code behind code
    Code:
    myCommand = myConn.CreateCommand();
    			myCommand.CommandText = "select * from tbl_firm";
    
    		    OracleDataAdapter oda = new OracleDataAdapter(myCommand);
    			DataSet myDs = new DataSet("Firms");
    			myCommand.Transaction = myOracleTransaction;
    			oda.Fill(myDs);
    			myCommand.ExecuteNonQuery();
    			GridFirms.DataSource = myDs;
    			GridFirms.DataBind();
    			myOracleTransaction.Commit();
    			this.myConn.Close();

    And this is my asp code :


    Code:
    <asp:datagrid id="GridFirms" runat="server" AutoGenerateColumns="False" GridLines="Vertical">
    							<AlternatingItemStyle BackColor="Silver"></AlternatingItemStyle>
    							<ItemStyle BackColor="DarkGray"></ItemStyle>
    							<HeaderStyle Font-Bold="True" BackColor="LightGray"></HeaderStyle>
    							<Columns>
    								<asp:BoundColumn DataField="FIRM_NAME" HeaderText="Firm">
    									<HeaderStyle Width="50px"></HeaderStyle>
    								</asp:BoundColumn>
    								<asp:BoundColumn DataField="FIRM_IS_OEM" HeaderText="OEM?">
    									<HeaderStyle Width="50px"></HeaderStyle>
    								</asp:BoundColumn>
    								<asp:BoundColumn DataField="FIRM_IS_TIER1" HeaderText="Tier1">
    									<HeaderStyle Width="50px"></HeaderStyle>
    								</asp:BoundColumn>
    								<asp:BoundColumn DataField="FIRM_IS_RECTICEL" HeaderText="Recticel?">
    									<HeaderStyle Width="50px"></HeaderStyle>
    								</asp:BoundColumn>
    								<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit">
    									<HeaderStyle Width="50px"></HeaderStyle>
    								</asp:EditCommandColumn>
    								<asp:ButtonColumn Text="Delete" CommandName="Delete">
    									<HeaderStyle Width="50px"></HeaderStyle>
    								</asp:ButtonColumn>
    								<asp:TemplateColumn HeaderText="Test">
    								 <ItemTemplate>
    								  <asp:CheckBox id=test Runat=server></asp:CheckBox>
    								 </ItemTemplate>
    								</asp:TemplateColumn>
    							</Columns>
    						</asp:datagrid>
    Last edited by Draven Chen Zhen; Apr 15th, 2005 at 01:28 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width