Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting CommandArgument for a Gridview
    primarykey
    data
    text
    <p>I want to set a CommandArgument for a Gridview but if I run the programm an error occured.</p> <p>Here is my ButtonField declaration:</p> <pre><code>&lt;asp:ButtonField Text="Löschen" CommandName="Deleterecord" ButtonType="Button" CommandArgument=&lt;% Eval("userId") %&gt; /&gt; </code></pre> <p>and this is the error:</p> <pre><code>Parser Error Message: Literal content ('&lt;asp:ButtonField Text="Löschen" CommandName="Deleterecord" ButtonType="Button" CommandArgument=') is not allowed within a 'System.Web.UI.WebControls.DataControlFieldCollection'. </code></pre> <p><strong>EDIT:</strong></p> <p>with these block of code I fill my Gridview:</p> <pre><code>protected void Button2_Click(object sender, EventArgs e) { Guid g = Guid.Parse("ef7a9f97-6a9a-44c6-ac38-82a5d06c394e"); RoutesManager rm = new RoutesManager(g); rm.GetAllRoutes(); List&lt;Route&gt; result; result=rm.GetAllRoutes(); GridView1.DataSource = result; GridView1.DataBind(); } </code></pre> <p>and this is GetallRoutes:</p> <pre><code> public List&lt;Route&gt; GetAllRoutes() { var inputParams = new Dictionary&lt;string, object&gt;(); var xmlHelper = new XmlHelper(); var result = new List&lt;Route&gt;(); inputParams.Add("UserId", _userId); DataTable dt = _dbhelper.Select("SELECT * FROM ROUTES WHERE UserId=@UserId", inputParams); foreach (DataRow row in dt.Rows) { var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(row[XmldocPosition].ToString()); result.Add(xmlHelper.ConvertXmlDocumentToRoute(xmlDoc.ToXDocument())); } return result; </code></pre> <p>}</p> <p>My grid view full with this block of code ,I put a link button in my Gridview for each Row and I want if the user click this button only this row is deleted from DB and Gridview</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload