[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 344
  • Last Modified:

Handling Recordset in ASP/NET/C#

This is a rather simple question but I just don't know how it's done in an ideal way in ASP.NET/C#.  Here's what I want to do:
1. On page load, execute a SQL query and read rows returned. (aspx.cs side)
2. Display the results and checkbox on each line. (aspx side)
3. User checks some/all lines and hits submit. (aspx side)
4. Loop thru the lines and process the checked lines. (aspx.cs side)

If it were PHP or something, I'd execute the SQL query, store the results into arrays, and then in HTML, loop thru the arrays to display with checkboxes and so forth.

Thanks,
0
stu29
Asked:
stu29
  • 5
  • 2
1 Solution
 
silemoneCommented:
1)  

string connectionstr = " ...";
SqlConnection objConn = new SqlConnection(connectionstr);
SqlCommand objComm = new SqlCommand("Select...", objConn);
SqlDataAdater  objDA = new SqlDataAdapter(objComm);
DataSet objDS = new Dataset();
objDa.Fill(objDS);
0
 
silemoneCommented:
2) what are you specs?  what is the data container that's going to display this?
you could use a repeater for this...

3)  again, this would be the repeater with a simple button

4) loop through the repeater, and check to see which lines are checked...

I gave a starting point...do you have any code?
0
 
silemoneCommented:
continuation of part 1) binding data to a repeater
MyRepeater.DataSource = ds
MyRepeater.DataBind()

place a repeater in your aspx page...


<ASP:Repeater id="MyRepeater" runat="server">
      <HeaderTemplate>
         <Table width="100%" style="font: 8pt verdana">
            <tr style="background-color:DFA894">
               <th>
                  Data:
               </th>
               <th>
                  CheckBox:              
               </th>
            </tr>
      </HeaderTemplate>
      <ItemTemplate>
            <tr style="background-color:FFECD8">
               <td>
                  <%# DataBinder.Eval(Container.DataItem, "title") %>
               </td>
               <td>
                  <asp:checkbox id="chk" runat="server" />
               </td>              
            </tr>
      </ItemTemplate>
      <FooterTemplate>
         </table>
      </FooterTemplate>
   </ASP:Repeater>
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
silemoneCommented:
is this for your website?
0
 
silemoneCommented:
by the way, the above was 2)
0
 
stu29Author Commented:
How do I do #4 exactly?
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now