1

I have a GridView with a non ASP object (INPUT type for suggestions) and i want to get the values from those forms to the code behind, how do I do it?

<ItemTemplate>
    <tr style="background-color: #E0FFFF; color: #333333;">
        <td style="text-align: left;padding-left:10px">
            <asp:Label ID="DESLabel" runat="server" Text='<%# Eval("DES") %>' />
        </td>
        <td style="text-align: left">
            <input id ="PROD" style="width:100%;Height:25px" />
        </td>
        <td>
            <asp:Label ID="PRODQUANTLabel" runat="server" Text='<%# Eval("PRODQUANT") %>' />
        </td>
        <td>
            <asp:TextBox ID="AVQUANTLabel" runat="server" Height="25px" Width="65px" Text='<%# Eval("AVQUANT") %>' />
        </td>
    </tr>
</ItemTemplate>

3 Answers 3

1

you can user findcontrol meyhod

in for loop or in RowUpdating Event

1.firt way in Loop, 2 RowUpdating Methid

 foreach (GridDataItem item in RadGrid1.Items)
    {
        string id = item["ID"].Text;
        string firstName = (item["TempColumn1"].FindControl("PRODQUANTLabel") as Lable).Text;
    }

protected void GridView1_RowUpdating(object sender,idViewUpdateEventArgs e)
  {
              GridView gv = (GridView)sender;
              GridViewRow gvRow = gv.Rows[e.RowIndex];
              Lable tb = (Lable) gridview1.FindControl("PRODQUANTLabel");
              if (tb == null)
                 throw new ApplicationException("Could not find Lable");

              string strValue= tb.Text;

   }
Sign up to request clarification or add additional context in comments.

1 Comment

It's the input data I need, not the Label, the asp controls are working fine.
0

You can get the value on code behind as any simple form post. To do that you first make sure that you have a name field on your input control.

<input id ="PROD" name="prod" style="width:100%;Height:25px" />

then on post back you can get the value using the Request.Form

var value = Request.Form["prod"]

2 Comments

Don't forget it's inside a listview wich means there is more than one with the same name and ID
@JoãoPedroSousa You need to handle that, either separate after the post back, either add extra numbers on the id (like prod.1, prod.2 etc)
0

I ended up using another method using asp texboxes. Still working on in.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.