Click here to Skip to main content
15,884,388 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: bound dropdownlist adding temp data Pin
C#Coudou8-Feb-11 21:21
C#Coudou8-Feb-11 21:21 
AnswerRe: bound dropdownlist adding temp data Pin
Anurag Gandhi8-Feb-11 22:06
professionalAnurag Gandhi8-Feb-11 22:06 
GeneralRe: bound dropdownlist adding temp data Pin
C#Coudou8-Feb-11 22:41
C#Coudou8-Feb-11 22:41 
GeneralRe: bound dropdownlist adding temp data Pin
Anurag Gandhi8-Feb-11 22:54
professionalAnurag Gandhi8-Feb-11 22:54 
QuestionCheckbox inside gridview. Pin
fififlowertot8-Feb-11 0:04
fififlowertot8-Feb-11 0:04 
AnswerRe: Checkbox inside gridview. Pin
Vimalsoft(Pty) Ltd8-Feb-11 20:10
professionalVimalsoft(Pty) Ltd8-Feb-11 20:10 
GeneralRe: Checkbox inside gridview. Pin
fififlowertot9-Feb-11 0:03
fififlowertot9-Feb-11 0:03 
GeneralRe: Checkbox inside gridview. Pin
Vimalsoft(Pty) Ltd9-Feb-11 19:14
professionalVimalsoft(Pty) Ltd9-Feb-11 19:14 
ok i see where your problem is. You assume if you add a checkbox, it will carry the ID of the checked field , that is not true. I normally create an extra template field and bind the label with the value and as you did on the server side, i find the label and get the value. I have compiled an example and this will help you

html

    <asp:GridView ID="GridView1" AutoGenerateColumns="False" runat="server" 
        DataSourceID="SqlDataSource1">
        <Columns>
            <asp:TemplateField>
            <ItemTemplate>
            <asp:CheckBox ID="chkAgency" runat="server" />
            </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
            <ItemTemplate>                     
            
            <asp:Label ID="lblid" runat="server" Text='<%# Eval("ID")%>'></asp:Label>
            </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField = "ID" HeaderText = "ID" InsertVisible="False" 
                ReadOnly="True" SortExpression="ID" />
            <asp:BoundField DataField ="Descr" HeaderText = "Descr" SortExpression="Descr"/>
            <asp:BoundField DataField = "LongName" HeaderText = "LongName" 
                SortExpression="LongName"/>
            <asp:BoundField DataField="Capacity" HeaderText="Capacity" 
                SortExpression="Capacity" />
            <asp:BoundField DataField="Note" HeaderText="Note" SortExpression="Note" />
     </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:TTBLv3MasterConnectionString %>" 
        SelectCommand="select * from dbo.TBL_VENUE"></asp:SqlDataSource>
<asp:Button ID="btntest" Text="Test" runat="server" onclick="btntest_Click" /> 


and the server side


protected void btntest_Click(object sender, EventArgs e)
   {
       foreach (GridViewRow row in GridView1.Rows)
       {

           CheckBox chk = (CheckBox)row.FindControl("chkAgency");


           Label lblid = (Label)row.FindControl("lblid");

           List<string> lstList = new List<string>();

           if (chk != null && chk.Checked)
           {
               //Response.Cookies["thistestcookie"].Value = row.Cells[0].Text.ToString();
               lstList.Add(lblid.Text);
           }
       }
   }


Thanks
Vuyiswa Maseko,

Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.

C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/

Questionfind runtime textbox value from grid Pin
Sneha Bisht7-Feb-11 19:52
Sneha Bisht7-Feb-11 19:52 
AnswerRe: find runtime textbox value from grid Pin
Parwej Ahamad8-Feb-11 0:08
professionalParwej Ahamad8-Feb-11 0:08 
QuestionHow can I get Session value in c#? Pin
buffering836-Feb-11 12:49
buffering836-Feb-11 12:49 
AnswerRe: How can I get Session value in c#? Pin
Shujaat Gul6-Feb-11 20:15
Shujaat Gul6-Feb-11 20:15 
AnswerRe: How can I get Session value in c#? Pin
Vimalsoft(Pty) Ltd7-Feb-11 20:15
professionalVimalsoft(Pty) Ltd7-Feb-11 20:15 
AnswerRe: How can I get Session value in c#? Pin
Ravi Sant3-May-11 0:20
Ravi Sant3-May-11 0:20 
Questionstrange box characters Pin
mnemonic696-Feb-11 2:29
mnemonic696-Feb-11 2:29 
AnswerRe: strange box characters Pin
Dhyanga7-Feb-11 6:14
Dhyanga7-Feb-11 6:14 
QuestionASP.NET+VB (LOGIN TO WEB SITE) Pin
Mujibulhaq5-Feb-11 20:00
Mujibulhaq5-Feb-11 20:00 
AnswerRe: ASP.NET+VB (LOGIN TO WEB SITE) Pin
Sandeep Mewara6-Feb-11 6:52
mveSandeep Mewara6-Feb-11 6:52 
AnswerRe: ASP.NET+VB (LOGIN TO WEB SITE) Pin
Vimalsoft(Pty) Ltd8-Feb-11 20:19
professionalVimalsoft(Pty) Ltd8-Feb-11 20:19 
QuestionI want to keep the Data access layer in a different class library project, but how can I manage Web.Config file ? Pin
Nadia Monalisa4-Feb-11 17:30
Nadia Monalisa4-Feb-11 17:30 
AnswerRe: I want to keep the Data access layer in a different class library project, but how can I manage Web.Config file ? Pin
Shahriar Iqbal Chowdhury/Galib6-Feb-11 9:04
professionalShahriar Iqbal Chowdhury/Galib6-Feb-11 9:04 
GeneralRe: I want to keep the Data access layer in a different class library project, but how can I manage Web.Config file ? Pin
Nadia Monalisa6-Feb-11 10:22
Nadia Monalisa6-Feb-11 10:22 
GeneralRe: I want to keep the Data access layer in a different class library project, but how can I manage Web.Config file ? Pin
Not Active6-Feb-11 11:27
mentorNot Active6-Feb-11 11:27 
QuestionASP.NET development on Mac OS X Pin
Paul Watson4-Feb-11 7:51
sitebuilderPaul Watson4-Feb-11 7:51 
AnswerRe: ASP.NET development on Mac OS X Pin
Eaverae10-Feb-11 4:50
Eaverae10-Feb-11 4:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.