CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
web_forms
getting_started
data_presentation_controls
dotnetnuke
data_access-sql_server_sql_server_express_and_sqldatasource_control
security
client_side_web_development
novell-support-groupwise-6x-clients
data_access-data_access_and_objectdatasource_control
asp-net_ajax-asp-net_ajax_control_toolkit
novell-support-netware-6x-install-upgrade
asp-net_ajax-asp-net_ajax_discussion_and_suggestions
novell-support-netware-6x-administration-tools
master_pages_themes_and_navigation_controls
configuration_and_deployment
novell-support-netware-client-winnt-2x-xp
novell-support-groupwise-7x-clients
asp-net_ajax-asp-net_ajax_ui
novell-support-edirectory-netware
community-free_for_all
visual_studio_2005
novell-support-groupwise-6x-install-setup
data_access-xml_and_xmldatasource_control
control-cancel
novell-support-iprint
advanced_asp-net-crystal_reports
data_access-xml_web_services
microsoft-public-access
novell-community-chat
state_management
novell-support-netware-6x-abends-hangs
dotnetnuke-getting_started
novell-support-groupwise-6x-gwia
-net_languages-c
novell-support-identity-manager-engine-drivers
novell-support-groupwise-discontinued
advanced_asp-net-architecture
opensuse-org-suse-linux-support-install-configure-administration
dotnetnuke-custom_modules
novell-support-groupwise-7x-install-setup-admin
novell-support-netware-6x-storage-media
novell-support-groupwise-6x-agents
installation_and_setup
data_access-access_databases_and_accessdatasource_control
windows-hosting_open_forum
visual_web_developer_2005_express
novell-support-groupwise-6x-web-access
novell-support-netware-6x-server-backup
macromedia-dreamweaver
novell-support-netware-5x-administration-tools
novell-support-ifolder
novell-support-bordermanager-install-setup
novell-support-imanager
microsoft-public-dotnet-framework-aspnet
novell-support-netware-5x-install-upgrade
novell-support-cluster-services
novell-support-bordermanager-proxies
novell-support-newsflash
advanced_asp-net-sql_server_reporting_services
microsoft-public-dotnet-languages-csharp
web_parts_and_personalization
about_this_site-feedback_on_this_website
ibm-software-websphere-portal-server
novell-support-netware-dns-dhcp
novell-support-zenworks-desktops-4x-app-launcher
-net_languages-visual_basic_-net
advanced_asp-net-custom_server_controls
novell-support-bordermanager-vpn
novell-support-ndps-neps
microsoft-public-sqlserver-programming
novell-support-netware-webserver
community-jobs
novell-support-netware-4x
advanced_asp-net-mobile_and_handheld_devices
internet_explorer_web_controls
novell-support-zenworks-desktops-4x-install-setup
novell-support-edirectory-linux
novell-support-groupwise-7x-gwia
development_tools-web_matrix_general_discussions
microsoft-public-access-formscoding
macromedia-flash
community-announcements
portal_starter_kit
novell-support-zenworks-desktops-4x-management-agent
novell-support-zenworks-patch-management
novell-support-native-file-access
microsoft-public-access-queries
microsoft-public-access-forms
novell-support-groupwise-7x-web-access
novell-support-netware-small-business-6x
data_access-active_directory_and_ldap
novell-support-edirectory-windows
novell-support-groupwise-7x-agents
novell-support-ichain
data_access-oracle
novell-support-zenworks-desktop-management-6x-imaging
novell-support-groupwise-7x-wireless
novell-support-netware-5x-abends-hangs
advanced_asp-net-localization
novell-support-zenworks-desktop-management-7x-imaging-server-nw-win




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > Asp.Net Forum > visual_studio.visual_studio_2005 Tags:
Item Type: Date Entered: 7/16/2007 10:13:55 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 5 Views: 69 Favorited: 0 Favorite
6 Items, 1 Pages 1 |< << Go >> >|
"s179999" <>
NewsGroup User
Extract records from sql server where one field is an array, split apart array and insert records into Gridview7/16/2007 10:13:55 PM

0

I currently brought the sql statement into list.vb and am splitting the array into elements.  The array could have up to 10 elements. I need to bring these results into list.aspx with a Gridview.  I want the Gridview to show the PrimaryKey then 10 checkboxs that are true/false depending on the array.  I haven't a qlue where to start. I get around vb.net fine but new to asp.net

"Benson Yu - MS
NewsGroup User
Re: Extract records from sql server where one field is an array, split apart array and insert records into Gridview7/19/2007 2:55:03 AM

0

Hi s179999,

From description, I understand that you want to display a GridView with two columns. First one is the PrimaryKey (ID), second one includes 10 checkboxs which selected or not depend on the data from SQL Server. Since you didn?t describe the array detailed. I suppose it is a string with separator (such as "true_false_true"). Even your array is the other type, the code logic is the same. Following is the demo for your reference.

<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:BoundField DataField="ID" HeaderText="ID" />
                <asp:TemplateField HeaderText="CheckBoxs">
                    <ItemTemplate>
                        <asp:CheckBoxList ID="CheckBoxList1" runat="server" ValidationGroup='<%# Eval("CheckBoxs")%>'>
                        </asp:CheckBoxList>
                    </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 cbl As CheckBoxList = DirectCast(e.Row.Cells(1).FindControl("CheckBoxList1"), CheckBoxList)
            Dim checkboxarray As String() = cbl.ValidationGroup.Split("_")
            For i As Integer = 0 To checkboxarray.Length - 1
                cbl.Items.Add(checkboxarray(i))
                cbl.Items(i).Selected = checkboxarray(i).Equals("true")
            Next
        End If
    End Sub

PS. For getting data from SQL Server, please refer to ADO.NET.

 


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.
"s179999" <>
NewsGroup User
Re: Extract records from sql server where one field is an array, split apart array and insert records into Gridview7/20/2007 12:06:54 AM

0

Very nicely done.  The only exception to this is I want the id & checkboxs in a single row.

Edit Id chk1 chk2 chk3 chk4 chk4 bla bla

The Edit hyperlink will not edit in this form but will Response.Redirect("Edit.aspx")

Thanks, Phil

"Benson Yu - MS
NewsGroup User
Re: Extract records from sql server where one field is an array, split apart array and insert records into Gridview7/20/2007 2:02:56 AM

0

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.
"s179999" <>
NewsGroup User
Re: Extract records from sql server where one field is an array, split apart array and insert records into Gridview7/20/2007 10:29:06 AM

0

|  Edit  |  id1  |  chk1 | chk2 | chk3 ?.  |
|  Edit  |  id2  |  chk1 | chk2 | chk3 ?.  |

 Each element is in its own column and will each have it's own header describing what the check box represents.

ie:

             ID  | Was the training helpful | Would you like additional training | Was your instructor helpful |
Edit        id1|              chk1               |                       chk2                    |                   chk3               |

Edit        id2|              chk1               |                       chk2                    |                   chk3               |

"Benson Yu - MS
NewsGroup User
Re: Extract records from sql server where one field is an array, split apart array and insert records into Gridview7/23/2007 6:33:28 AM

0

Hi Phil,

Please refer to the following code.

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" 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>
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Edit</asp:LinkButton>
                        <asp:Label ID="Label1" runat="server" Style="display: none" Text='<%# Eval("CheckBoxs")%>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="ID" HeaderText="ID" />
                <asp:TemplateField HeaderText="Was the training helpful">
                    <ItemTemplate>
                        <asp:CheckBox ID="CheckBox1" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Would you like additional training">
                    <ItemTemplate>
                        <asp:CheckBox ID="CheckBox2" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Was your instructor helpful">
                    <ItemTemplate>
                        <asp:CheckBox ID="CheckBox3" runat="server" />
                    </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 i As Integer = 2, j As Integer = 0
            While i < e.Row.Cells.Count
                Dim label1 As System.Web.UI.WebControls.Label = DirectCast(e.Row.Cells(0).FindControl("Label1"), System.Web.UI.WebControls.Label)
                Dim checkboxarray As String() = label1.Text.Split("_")

                Dim cb As System.Web.UI.WebControls.CheckBox = DirectCast(e.Row.Cells(i).Controls(1), System.Web.UI.WebControls.CheckBox)
                cb.Checked = checkboxarray(j).Equals("true")
                i += 1
                j += 1
            End While
        End If
    End Sub

    Protected Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Response.Redirect("WebForm1.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.
6 Items, 1 Pages 1 |< << Go >> >|


Free Download:













error while installing team explorer

visual studio and vwd2005 memory leak problem

where are moblie asp.net projects? (vs2005 prof)

error message when publishing project with vs.net using copy project

open and close an ascx file in vs 2005

getting a custom control to show up in the toolbox

installing a trial version of visual studio 2005

debug | attach to process

visual studio 2005 service pack 2 (hoping for)

vs 2005 web application projects - deployment / copy website / publish

random error: is already declared as 'protected dim withevents

i thought studio would highlight begin and end of logic?

debuger nightmare - idle timeout after 5 seconds

breaking changes between released b2 and july ctp?

dataset designer issue

rollback setup when custom actions fail

just in time debugger

visual studio 2005 web application project next version

deploy web application in vs 2005

changing vss databases in studio

name change of control in properties window doesn't work

problems with designer

version numbers

adding the images to this box?

few questions about visual studio academic version

"build website"

enabling of the debugfunction

adding standard .aspx page to precomiled application

web application project and profile api

visual studio 2005 and .net framework 1.1

web site administration tool in vs 2005

adding a web application project to the global assembly cache causes problem in configure data source

vs 2005 and fpse on a remote server or not???

problem: "failed to grant required minimum permissions..."

cannot create a webproject in vs 2005

not supported by msbuild and cannot be built.

debugging with stepinto and step over

recent projects menu only showing open/create for project and not for website

built-in web server

can i compile vb6 files using vs 2005?

drag and drop in ide (vs2005 pro)

moving a project from one copy of visual studio to another

error compiling the code on 2005: error 289

question on project dependency

web deployment project and encoding

option strict

debugging web services

class library standard

using iis as development server rather than built in asp.net 2.0 server?

assemblyinfo.vb

 
Search This Site:

 
  Privacy | Contact Us
All Times Are GMT