Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
I am developing the client side validation on grid view . please give me the answer as soon as possible
Posted 26-Jul-12 3:08am
Edited 26-Jul-12 3:32am
v2
Comments
Vani Kulkarni at 26-Jul-12 9:33am
   
Removed urgency.
Vani Kulkarni at 26-Jul-12 9:35am
   
What have you tried till now? Post the specific code where you are facing issue.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Did you try anything? Please do make an effort, you may find it's not that difficult.
 
These articles will help you to learn:
JQuery to Enable and Disable Textbox when CheckBox is Checked with Gridview [^]
Check/uncheck CheckBox in a GridView using Javascript[^]
Enable textbox in gridview on click checkbox [^]
  Permalink  
Comments
CIDev at 26-Jul-12 10:01am
   
Good advice, worth a +5.
Sandeep Mewara at 26-Jul-12 13:25pm
   
Thanks.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Giving you a ready sample. Say below is your grid view
 
<asp:GridView ID="gvM" runat="server">
        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:CheckBox runat="server" ID="chkIs" onclick="GetCheckStatus()"></asp:CheckBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:TextBox runat="server" ID="txtId"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField AccessibleHeaderText = "Name" DataField="Name" />
        </Columns>
    </asp:GridView>
Have a script which will be called every time when the ckeck box is checked or unchecked.
<script language="javascript" type="text/javascript">
function GetCheckStatus() {
 var srcControlId = event.srcElement.id;
 var targetControlId = event.srcElement.id.replace('chkIs', 'txtId');
 if (document.getElementById(srcControlId).checked)
      document.getElementById(targetControlId).disabled = false;
 else
      document.getElementById(targetControlId).disabled = true;
}
        </script>
In your aspx.cs page bind the grid with appropriate data source as below.
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("Name");
DataRow dr = dt.NewRow();
dr["Name"] = "Das";
dt.Rows.Add(dr);
DataRow dr1 = dt.NewRow();
dr1["Name"] = "Shon";
dt.Rows.Add(dr1);
gvM.DataSource = dt;
gvM.DataBind();
}
  Permalink  
Comments
momo14 at 1-Nov-12 11:03am
   
Very Very Nice solution,
I like this.
Thank you very much
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Check this article. I have explained how to make fields editable and noneditable inside gridview using checkbox.
 
http://www.c-sharpcorner.com/UploadFile/1a81c5/non-editable-fields-in-Asp-Net-gridview/[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,696
1 Sergey Alexandrovich Kryukov 6,675
2 CPallini 5,315
3 George Jonsson 3,584
4 Gihan Liyanage 2,650


Advertise | Privacy | Mobile
Web02 | 2.8.140921.1 | Last Updated 26 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100