Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > GridView, DropDownList, SQLDataSources.... ugh.

Reply
Thread Tools

GridView, DropDownList, SQLDataSources.... ugh.

 
 
Ryan Marrs
Guest
Posts: n/a
 
      05-02-2006
Hey guys, I'm working on CommerceStarterKit, modifying it to fit a friend's
needs. There are two issues I'm running into during this, and I'm about
spent.

Issue #1: Setting the SelectedValue of the DropDownList in the template
column based on the field ParentID bound to the datagrid.

Issue #2: Getting the SelectedValue to pass to a ControlParameter (or
FormParameter, or ANY Parameter for that matter) for the update call in the
SQLDataSource.

I suppose I could do most of this through the backend, but I'm really
interested in trying this through the controls provided.

Thanks in advance!

Thanks,
Ryan

<%@ Page Language="vb" MasterPageFile="~/admin.master"
AutoEventWireup="true" CodeFile="admin_categories.aspx.vb"
Inherits="admin_categories" Title="Product Categories"
StylesheetTheme="White" %>
<asp:Content ID="Content1" ContentPlaceHolderID="AdminPlaceHolder"
Runat="Server">
<h1>Product Categories</h1>
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False" AutoGenerateDeleteButton="True"
DataKeyNames="CategoryID" DataSourceID="SqlDataSource1">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:TemplateField HeaderText="Parent"
SortExpression="Parent">
<EditItemTemplate>
<aspropDownList ID="CategoryParentDropDownList"
runat="server" DataTextField="CategoryName" DataValueField="CategoryID"
DataSourceID="sqldsCategories" />
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="CategoryParent" runat="server"
Text='<%# Bind("Parent") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ParentID" Visible="False" />
<asp:BoundField DataField="CategoryName"
HeaderText="CategoryName" SortExpression="CategoryName" />
<asp:BoundField DataField="CategoryID"
HeaderText="CategoryID" InsertVisible="False" ReadOnly="True"
SortExpression="CategoryID" />
</Columns>
</asp:GridView>
<asp:HiddenField ID="Something" Value="0" runat="server" />

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:CommerceTemplate %>"
SelectCommand="SELECT C2.[CategoryName] as Parent, C2.[CategoryID] as
ParentID, C1.[CategoryID], C1.[CategoryName] FROM [CMRC_Categories] C1 LEFT
JOIN [CMRC_Categories] C2 ON C1.CategoryParentID=C2.CategoryID"
DeleteCommand="DELETE FROM [CMRC_Categories] WHERE [CategoryID] =
@CategoryID"
InsertCommand="INSERT INTO [CMRC_Categories] ([CategoryName],
[CategoryParentID]) VALUES (@CategoryName, @CategoryParentID)"
UpdateCommand="UPDATE CMRC_Categories SET CategoryName = @CategoryName,
CategoryParentID = @CategoryParentID WHERE (CategoryID = @CategoryID)">
<DeleteParameters>
<asparameter Name="CategoryID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asparameter Name="CategoryName" Type="String" />
<asp:ControlParameter Name="CategoryID" ControlID="GridView1"
PropertyName="SelectedValue" Type="Int32" />
<asparameter Name="CategoryID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asparameter Name="CategoryName" Type="String" />
<asparameter Name="CategoryParentID" />
</InsertParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="sqldsCategories" runat="server"
ConnectionString="<%$ ConnectionStrings:CommerceTemplate %>"
SelectCommand="SELECT [CategoryID], [CategoryName] FROM [CMRC_Categories]"
/>
</asp:Content>



 
Reply With Quote
 
 
 
 
ankit aggarwal
Guest
Posts: n/a
 
      05-02-2006




*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments