Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I have a GridView in my asp.net Applicaiton. i have a Button with javascript function which shows the values of selected row in Div. How to get all Grid Column values of Selected Row on ButtonClick.

enter image description here Javascript:

function SetRowValues(id, controlid, fair, good, mint, nnew, poor,broken) {
            //alert(id + " " + fair + " " + controlid);
            $("#divSelectedRow").html("TPCCID: " + id + " Fair:" + fair + " Good: " + good + " Mint: " + mint + " New: " + nnew + " Poor: " + poor + " Broken: " + broken);
            $("#divSelectedRow").css("display", "block");
            return false;
    }

Grid Markup:

<asp:TemplateField HeaderText="Source" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center"
    HeaderStyle-HorizontalAlign="Center">
    <ItemTemplate>
 <asp:Button ID="BtnSource" runat="server" CausesValidation="false" OnClick='<%# "return SetRowValues("+Eval("ttppcid")+",this.id,"+Eval("Fair")+","+Eval("Good")+","+Eval("Mint")+","+Eval("Poor")+","+Eval("Broken")+")"%>' Text="Source" />
  </ItemTemplate>
</asp:TemplateField>

Here, i want to get all the column values of selected row using Javascript. Note: When the Value for column1 is string containing Space eg: "Cell Phone" then the script wont work. Please help me to get the entire row values using javascript on Button Click.

Help Appreciated!

share|improve this question

I think you have make mistake in preparing the Javascript function call.

Missing single quote around parameters '' .

<asp:TemplateField HeaderText="Source" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center"
    HeaderStyle-HorizontalAlign="Center">
    <ItemTemplate>
 <asp:Button ID="BtnSource" runat="server" CausesValidation="false" 
OnClick='<%# "return SetRowValues('"+Eval("ttppcid")+"',this.id,'"+Eval("Fair")+"','"+Eval("Good")+"','"+Eval("Mint")+"','"+Eval("Poor")+"','"+Eval("Broken")+"')"%>' Text="Source" />
  </ItemTemplate>
</asp:TemplateField>
share|improve this answer
    
nope it gives error servertag is not well formed..! :( – SHEKHAR SHETE Jan 30 '14 at 9:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.