0

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!

1 Answer 1

0

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>
0

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.