Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complex datagrid questions.

Status
Not open for further replies.

qwert231

Programmer
Sep 4, 2001
756
US
I realized that for laying out stuff dataGrids are really versatile. So I put a grid together that shows print sizes based on the film type. I have a table like this:
packID packName packDesc 35 6x6 6x45 spPrice mounting
0000 wal 8 Wallets x x x
0001 3x5 4- 3x5s x .65
0002 4x5 4- 4x5s x x .65
0003 5x5 2- 5x5s x .65
0004 11x14 1- 11x14 x x x 1.25 x

So my query goes like this:
Code:
Select Case flmType
 Case "35mm"
  strSql = "SELECT packID, packDesc, spPrice, mounting FROM wedPacks WHERE [35] = True"
 Case "6x45"
  strSql = "SELECT packID, packDesc, spPrice, mounting FROM wedPacks WHERE [6x45] = True"...

My datagrid ends up looking like this:
Code:
<asp:datagrid id=&quot;dgPrntSize&quot; runat=&quot;server&quot; AutoGenerateColumns=&quot;False&quot;>
 <ItemStyle HorizontalAlign=&quot;Center&quot;></ItemStyle>
 <HeaderStyle HorizontalAlign=&quot;Center&quot;></HeaderStyle>
 <Columns>
  <asp:TemplateColumn HeaderText=&quot;Qty&quot;>
   <ItemTemplate>
    <asp:TextBox id=&quot;TextBox2&quot; runat=&quot;server&quot; Width=&quot;30px&quot;></asp:TextBox>
   </ItemTemplate>
  </asp:TemplateColumn>
  <asp:TemplateColumn HeaderText=&quot;Print Size&quot;>
   <ItemTemplate>
    <%# container.DataItem (&quot;packDesc&quot;) %>
   </ItemTemplate>
  </asp:TemplateColumn>
  <asp:TemplateColumn HeaderText=&quot;Mount&quot;>
   <ItemTemplate>
    <asp:dropdownlist id=&quot;Mount&quot; tabIndex=&quot;12&quot; runat=&quot;server&quot; Visible='<%# container.DataItem (&quot;mounting&quot;) %>'>
     <asp:listitem id=&quot;mNone&quot; runat=&quot;server&quot; value=&quot;None&quot; />
     <asp:listitem id=&quot;aMount&quot; runat=&quot;server&quot; value=&quot;Art Board&quot; />
     <asp:listitem id=&quot;cMount&quot; runat=&quot;server&quot; value=&quot;Canvas&quot; />
    </asp:dropdownlist>
   </ItemTemplate>
  </asp:TemplateColumn>
  <asp:TemplateColumn HeaderText=&quot;Spray&quot;>
   <ItemTemplate>
    <asp:CheckBox id=&quot;CheckBox1&quot; runat=&quot;server&quot; Visible='<%# isSpray(container.DataItem (&quot;spPrice&quot;)) %>'>
' This returns a boolean.
Code:
    </asp:CheckBox>
   </ItemTemplate>
  </asp:TemplateColumn>
 </Columns>
</asp:datagrid>

While this does display, with little code, exactly how I want it to, how should I go about retrieving the values?

Or, should I go about this another way?
 
Set up an editItemTemplate under each templateColumn, and also add a button column that will fire the edit command and the update command. You then specify an event handler for the update_command of the datagrid, and grab your values through the eventArgs argument to that function.

I'd suggest a search on Google for datagrid, or the fellows over at 4guysfromrolla have a good multi-part datagrid FAQ and walkthrough that goes over these basic tenants of the datagrid, and how to use them.

If you get stuck on specific points, then post back, and we'll get through them.
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top