Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataGrid Update Woes
Message
From
13/09/2002 02:47:34
 
 
To
All
General information
Forum:
ASP.NET
Category:
Web forms
Title:
DataGrid Update Woes
Miscellaneous
Thread ID:
00700056
Message ID:
00700056
Views:
47
I have a datagrid all decked out with my data using code. I am having mucho issues with the update method whos code is far too shamefull to show in public. I would also like to know how to bind the DS fields to the datagrid. I guess because I didn't use wizards I get punished. :( If I choose to automatically create columns all is well except my user can try to change my UID col...
Please be patient as I have been working with .NET for < 1 week. I am MCPx2 VB6 dist/desktop I feel like a beginner again and my ego is quite sore.
    Private Sub BindGrid(Optional ByVal SortField As String = "Eventdate")

        Dim strUID, strSQL As String
        strUID = DeCrypt(Session("UID"))
        strSQL = "select Registry_ID as [ID] ,RegistryName As [Registry Name], RegistryDesc As [Description], " & _
                 "EventDate as [Event Date] from registry where registrant_ID ='" & strUID & "' order by '" & SortField & "'"

        Dim DS As DataSet
        Dim MyConnection As New SqlConnection()
        Dim MyCommand As SqlDataAdapter

        MyCommand = New SqlDataAdapter(strSQL, SQLcn)

        DS = New DataSet("MyRegistryDS")
        MyCommand.Fill(DS, "registry")

        grdReg.DataSource = DS.Tables("registry").DefaultView
        'Source.Sort = E.SortExpression
        'grdReg.Columns(1).ItemStyle.Width = System.Web.UI.WebControls.Unit.Pixel(1)


        Page.DataBind()
        MyConnection.Close()
        strLastSortField = SortField
    End Sub
My Datagrid source looks like this: (My apologis for the mangled code but it was unmanagably wide in the preview.
<asp:datagrid id="grdReg" runat="server" Width="719px" Height="117px" Font-Names="Arial" 
BorderColor="#BE9A64" BorderStyle="None" CellSpacing="4" BorderWidth="1px" 
BackColor="#DEBA84" CellPadding="3" HorizontalAlign="Center" AllowPaging="True" 
AllowSorting="True" GridLines="Horizontal" PageSize="5"><SelectedItemStyle Font-Bold="True" 
ForeColor="White" BackColor="#738A9C"></SelectedItemStyle><ItemStyle Wrap="False" 
ForeColor="#8C4510" BackColor="#FFF7E7"></ItemStyle><HeaderStyle Font-Size="Smaller" Font-
Names="Arial" Font-Bold="True" Wrap="False" HorizontalAlign="Center" ForeColor="SaddleBrown" 
VerticalAlign="Middle" BackColor="#BE9A64"></HeaderStyle><FooterStyle ForeColor="#8C4510" 
BackColor="#F7DFB5"></FooterStyle>
<Columns><asp:EditCommandColumn ButtonType="PushButton" UpdateText="Update" 
CancelText="Cancel" EditText="Edit Registry"></asp:EditCommandColumn></Columns>
<PagerStyle Font-Size="XX-Small" Font-Names="Arial Black" HorizontalAlign="Center" 
ForeColor="#8C4510" Position="TopAndBottom" 
Mode="NumericPages"></PagerStyle></asp:datagrid><STRONG></span></form>
~Joe Johnston USA

"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams

Next
Reply
Map
View

Click here to load this message in the networking platform