如何使用datalist更新数据库 [英] how can update databasse using datalist

查看:85
本文介绍了如何使用datalist更新数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用asp.net中的数据列表在c#我的代码看起来像这样我已经使用了datalise之外的按钮现在用户再次检查checkbok并且只检查了行的值在表中更新,任何机构都可以告诉我如何当用户随机复选复选框时,代码是什么,单击按钮,只检查行的有效列,由一个更新

i am using a data list in asp.net in c# my code is looking like this i have use a button outside the datalise now user check the checkbok rendomly and only checked row's value updated in table , can any body tell me how to and what is the code when user heck the check box rendomly and click the button only checked row's valid column ill be updateed by one

<asp:DataList ID="DataList2" runat="server" Height="772px" Width="953px" 

            BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" 

            CellPadding="4" ForeColor="Black" GridLines="Horizontal">
            <footerstyle backcolor="#CCCC99" forecolor="Black" />
            <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" 

                Font-Italic="False" Font-Overline="False" Font-Strikeout="False" 

                Font-Underline="False" HorizontalAlign="Left" VerticalAlign="Middle" />
            <itemtemplate>
                <table align="center" class="style1" style="height: 85px">
                    <tr>
                        <td rowspan="2" style="width: 65px">
                            <asp:CheckBox ID="valid" runat="server" Text="Valid" />
                        </td>
                        <td class="style2" rowspan="3" style="width: 80px">
                            <asp:Image ID="pimage" runat="server" ImageUrl='<%# Eval("pimage") %>' Height="80px" Width="70px" />
                        </td>
                        <td class="style2" rowspan="3" style="width: 80px">
                            <asp:Image ID="snap2" runat="server" ImageUrl='<%# Eval("snap2") %>' Height="80px" Width="70px" />
                        </td>
                        <td class="style2" rowspan="3" style="width: 80px">
                            <asp:Image ID="snap3" runat="server" ImageUrl='<%# Eval("snap3") %>' Height="80px" Width="70px" />
                        </td>
                        <td style="width: 50px; height: 51px;">
                            <asp:Label ID="pid" runat="server" Text='<%# Eval("pid") %>' >
                        </td>
                        <td style="width: 50px; height: 51px;">
                            <asp:Label ID="categ" runat="server" Text='<%# Eval("categ") %>' >
                        </td>
                        <td style="width: 50px; height: 51px;">
                            <asp:Label ID="pdetails" runat="server" Text='<%# Eval("pdetails") %>' >
                        </td>
                        <td style="width: 50px; height: 51px;">
                            <asp:Label ID="pprice" runat="server" Text='<%# Eval("pprice") %>' >
                        </td>
                        <td style="width: 50px; height: 51px;">
                            <asp:Label ID="pname" runat="server" Text='<%# Eval("pname") %>' >
                        </td>
                        <td style="width: 50px; height: 51px;">
                            <asp:Label ID="uemail" runat="server" Text='<%# Eval("uemail") %>' >
                        </td>
                        <td style="width: 50px; height: 51px;">
                            <asp:Label ID="ucontect" runat="server" Text='<%# Eval("ucontect") %>' >
                        </td>
                        <td style="width: 50px; height: 51px;">
                            <asp:Label ID="ulocation" runat="server" Text='<%# Eval("ulocation") %>' >
                        </td>
                        <td class="style2" style="width: 50px; height: 51px;">
                            <asp:Label ID="uname" runat="server" Text='<%# Eval("uname") %>' >
                        </td>
                        <td style="height: 51px">
                            </td>
                        <td style="height: 51px">
                            </td>
                    </tr>
                    <tr>
                        <td colspan="11" rowspan="2">
                             </td>
                    </tr>
                    <tr>
                        <td style="width: 65px">
                             </td>
                    </tr>
                </table>
            </itemtemplate>
            <SelectedItemStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />

推荐答案

点击该按钮,循环显示所有行 DataList 并在循环内获取 CheckBox



如果选中,请更新该行。



gr的一个例子idView - 此处 [ ^ ]。你需要实现类似的东西。
On that button click, loop through all the rows of DataList and fetch the CheckBox inside the loop.

If it is checked, update the row.

One example with GridView - here[^]. You need to implement something similar.


这篇关于如何使用datalist更新数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆