Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want a column for checkbox in the gridview and next column for sequence using textbox when i checked the checkbox then sequence textbox show 1 next time if i checked another checkbox in the list then show in the sequence textbox value is 2 and so on.........my coding is that but problem arises for 11 value it show 10 when times of 12 it show 10 this process is for 11 to 19 when times of 20 then it show correct

checkbox sequence commodity
fill 1 a
blank blank b
fill 2 c
blank blank d
blank blank e
blank blank f
fill 3 g

C#
protected void grd_comm_grp_SelectedIndexChanged(object sender, EventArgs e)
{
     CheckBox cbSelection = (CheckBox)sender;
    GridViewRow row = (GridViewRow)cbSelection.NamingContainer;
    TextBox CenterSequence = (TextBox)row.FindControl("CenterSequence");
    // If Checked
    if (cbSelection.Checked)
    {
        // Enable the TextBox
        CenterSequence.Enabled = true;

        // Find Rows with sequence value
      var  ValidSequences = grd_comm_grp.Rows.Cast<GridViewRow>().Where(a => ((TextBox)a.FindControl("CenterSequence")).Text != "").ToList();
        // If there are any sequences, increment by 1
        if (ValidSequences.Count > 0)


            CenterSequence.Text = (Convert.ToInt32(ValidSequences.Max(a => ((TextBox)a.FindControl("CenterSequence")).Text)) + 1).ToString();



        // If new, put 1
        else
            CenterSequence.Text = "1";

    }
Posted
Updated 28-Jul-11 1:57am
v4
Comments
Manfred Rudolf Bihy 28-Jul-11 5:51am    
What he says?
LittleYellowBird 28-Jul-11 5:58am    
Hi, I think you need to rephrase you question, it is not very clear what you are asking. OK? :)

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900