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

Try this instead, remove the SelectCommand property and SelectParameters: <asp:SqlDataSource ID=”SqlDataSource1″ runat=”server” ConnectionString=”<%$ ConnectionStrings:itematConnectionString %>”> Then in the code behind do this: SqlDataSource1.SelectParameters.Add(“userId”, userId.ToString()); SqlDataSource1.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” While this worked for me, the following code also … Read more

GridView with merged cells

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 gvRow = GridView1.Rows[rowIndex]; GridViewRow gvPreviousRow = GridView1.Rows[rowIndex + 1]; for (int cellCount = 0; cellCount < gvRow.Cells.Count; cellCount++) { if (gvRow.Cells[cellCount].Text == gvPreviousRow.Cells[cellCount].Text) { … Read more