sqldatasource

How to pass a variable to the SelectCommand of a SqlDataSource?

余生长醉 提交于 2019-11-27 06:41:34
I want to pass variable from the code behind to the SelectCommand of a SqlDataSource? I don't want to use built-in parameter types (like ControlParameter, QueryStringParameter, etc) I need to pass a variable, but the following example does not work: <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:itematConnectionString %>" SelectCommand = "SELECT items.name, items.id FROM items INNER JOIN users_items ON items.id = users_items.id WHERE (users_items.user_id = @userId) ORDER BY users_items.date DESC" > <SelectParameters> <asp:Parameter DefaultValue="<

SqlDataSource vs ObjectDataSource

老子叫甜甜 提交于 2019-11-27 01:37:19
问题 If a web page needs some data, why not just have a SQLDataSource call a stored procedure? Why use an ObjectDataSource to call a business object that then calls the stored procedure? I understand that other apps (lets say desktop apps) built on the .net framework can access the business objects, but what if the application will always be only a web app? To be more clear: When should one use an SqlDataSource or ObjectDataSource ? How does one motivate the choice? 回答1: Having just a

GridView with merged cells

筅森魡賤 提交于 2019-11-26 14:03:15
问题 I need to display data in grid view with merged rows for some columns. Please help me to prepare a grid view in below defined format: And the original data comes from database is in below format: Please help me to find best way for doing this task dynamically and efficiently. 回答1: You will have to use RowSpan . Refer following code for it: protected void GridView1_DataBound1(object sender, EventArgs e) { for (int rowIndex = GridView1.Rows.Count - 2; rowIndex >= 0; rowIndex--) { GridViewRow

How to pass a variable to the SelectCommand of a SqlDataSource?

若如初见. 提交于 2019-11-26 12:07:26
问题 I want to pass variable from the code behind to the SelectCommand of a SqlDataSource? I don\'t want to use built-in parameter types (like ControlParameter, QueryStringParameter, etc) I need to pass a variable, but the following example does not work: <asp:SqlDataSource ID=\"SqlDataSource1\" runat=\"server\" ConnectionString=\"<%$ ConnectionStrings:itematConnectionString %>\" SelectCommand = \"SELECT items.name, items.id FROM items INNER JOIN users_items ON items.id = users_items.id WHERE