visuel studio 2008/recuperer la valeur d'une cellule du gridview

visuel studio 2008/recuperer la valeur d'une cellule du gridview - C#/.NET managed - Programmation

Marsh Posté le 01-12-2009 à 11:22:37    

bjr
je travaille avec visuel studio 2008, j'ai créee un gridview1 qui a une sqldatasource , et ce gridview1 n'affiche qu'une seule valeur, je veux recuperer cette valeur et la mettre dans un textbox1.
j'ai créee un bouton dals l'evenement click on j'ai mis le code suivant:  
textbox1.text = gridview1.selectedrow.cells(2).text
mais sa me donne l'erreur suivante: la reference d'objet n'est pas definie à une instance d'objet.
y a qlqun qui pourra me guider au moins l'erreur c quoi
merci

Reply

Marsh Posté le 01-12-2009 à 11:22:37   

Reply

Marsh Posté le 01-12-2009 à 12:59:25    

ça veut dire que tu essaies d'accéder à un objet dont la référence est à Null (un objet qui n'existe pas quoi)


---------------
J'ai un string dans l'array (Paris Hilton)
Reply

Marsh Posté le 01-12-2009 à 15:02:34    

Tu peux également voir si, par hasard, il ne faut pas utiliser l'activerow plutôt que la selectedrow.

 

Si ta ligne est associée à un objet, fais un cast, ce sera plus clair niveau code.

 

Sinon, comme les autres, mets un point d'arrêt au besoin.


Message édité par Fred999 le 01-12-2009 à 15:02:50
Reply

Marsh Posté le 01-12-2009 à 15:28:54    

re
me revoila
j'ai essayer de debogger mon programme et le resultat que textbox1 est vide, mais initialement le textbox1 est vide et je dois mettre la valeur de la cellule gridview1 dedans; la vraiment je ne sais quoi faire et suis totalement bloquée,  
et pour activerow mon visuel studio2008 ne le reconnais pas
alors pourrais jr avoir une aide de votre part?

Reply

Marsh Posté le 01-12-2009 à 15:50:21    

pardon c'est textbox1.text qui est null
texbox1 est un textbox.

Reply

Marsh Posté le 01-12-2009 à 16:01:09    

pardon c textbox1.text qui est nulle
textbox1 est un textbox
je suis tjr bloquée

Reply

Marsh Posté le 01-12-2009 à 16:06:25    

Si tu alloues une valeur à textbox1.text, il ne devrait pas y avoir de souci.
 
Le problème ne peut donc venir que de gridview1.selectedrow.cells(2).text, as-tu bien tout vérifié dans ce bout de code ?

Reply

Marsh Posté le 01-12-2009 à 16:12:54    

comment pourrais jr vérifier ce bout de code?
vraiment je n'en sais pas ou es le pbl et je bloque vraiment, je n'arrive pas a avancer
sos

Reply

Marsh Posté le 01-12-2009 à 16:15:31    

Visual Studio 2008 inclut ce qui est certainement le meilleur debugger du marché, il serait bien d'apprendre à l'utiliser :sarcastic:


---------------
J'ai un string dans l'array (Paris Hilton)
Reply

Marsh Posté le 02-12-2009 à 09:08:11    

bonjour
voila j'ai utiliser le debogguer et la j'ai pu savoir que textbox1.text est null, mais pour le gridview.selectedrow.cell(1) il ne fournit aucune information. (en  fait mon gridview ne contient que deux cellules, la premiere contient le nom de la colonne et la deuxieme contient la valeur que je veux mettre dans le textbox)

Reply

Marsh Posté le 02-12-2009 à 09:08:11   

Reply

Marsh Posté le 02-12-2009 à 10:03:17    

Ca reste flou, en fait t'avais pas utilisé le bon indice ? C'est résolu ?
 
(reprécisons, les indices commencent à zéro)

Reply

Marsh Posté le 02-12-2009 à 10:06:53    

non c tjr pas resolu

Reply

Marsh Posté le 02-12-2009 à 10:08:51    

bon écoute, poste le code complet parce que là on navigue de supputations en hypothèses et c'est pénible et improductif.


---------------
J'ai un string dans l'array (Paris Hilton)
Reply

Marsh Posté le 02-12-2009 à 10:24:01    

la page aspx est:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="page1.aspx.vb" Inherits="page1" %>
 
<%@ Register assembly="DevExpress.Web.ASPxGridView.v9.1, Version=9.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView" tagprefix="dxwgv" %>
<%@ Register assembly="DevExpress.Web.ASPxEditors.v9.1, Version=9.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dxe" %>
 
<%@ Register assembly="System.Web.DynamicData, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.DynamicData" tagprefix="cc1" %>
 
<%@ Register assembly="DevExpress.Web.v9.1, Version=9.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPopupControl" tagprefix="dxpc" %>
 
<%@ Register assembly="DevExpress.Web.ASPxScheduler.v9.1, Version=9.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxScheduler" tagprefix="dxwschs" %>
 
<%@ Register assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" namespace="System.Web.UI.WebControls" tagprefix="asp" %>
 
<%@ Register assembly="DevExpress.Web.v9.1, Version=9.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxDataView" tagprefix="dxdv" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        #form1
        {
            height: 639px;
            width: 1014px;
            margin-right: 285px;
        }
        .style3
        {
            width: 32px;
        }
        .style8
        {
            width: 32px;
            height: 22px;
        }
        .style11
        {
            width: 131px;
        }
        .style12
        {
            width: 144px;
            height: 22px;
        }
        .style13
        {
            width: 144px;
        }
        .style14
        {
            width: 7px;
            height: 22px;
        }
        .style15
        {
            width: 7px;
        }
        .style16
        {
            width: 163px;
            height: 22px;
        }
        .style17
        {
            width: 163px;
        }
        .style18
        {
            width: 173px;
            height: 22px;
        }
        .style19
        {
            width: 173px;
        }
        .style20
        {
            width: 76px;
            height: 22px;
        }
        .style21
        {
            width: 76px;
        }
        .style22
        {
            width: 50px;
            height: 22px;
        }
        .style23
        {
            width: 50px;
        }
        .style24
        {
            width: 47px;
        }
        .style25
        {
            width: 50px;
            font-weight: bold;
            height: 25px;
        }
        .style26
        {
            width: 7px;
            font-weight: bold;
            height: 25px;
        }
        .style27
        {
            width: 32px;
            font-weight: bold;
        }
        .style28
        {
            width: 100%;
            font-size: 10pt;
            font-family: Arial, Helvetica, sans-serif;
        }
        .style31
        {
            width: 182px;
        }
        .style33
        {
            width: 118px;
            font-weight: bold;
            font-size: 10pt;
            font-family: Arial, Helvetica, sans-serif;
        }
        .style37
        {
            width: 118px;
            font-weight: bold;
        }
        .style39
        {
            width: 118px;
            height: 96px;
        }
        .style40
        {
            height: 96px;
        }
        .style42
        {
            width: 182px;
            height: 96px;
        }
        .style47
        {
            width: 199px;
        }
        .style48
        {
            height: 96px;
            width: 199px;
        }
        .style54
        {
            width: 117px;
            height: 12px;
        }
        .style55
        {
            width: 117px;
            font-weight: bold;
        }
        .style56
        {
            width: 117px;
            height: 96px;
        }
        .style61
        {
            width: 77px;
        }
        .style62
        {
            width: 77px;
            height: 96px;
        }
        .style64
        {
            width: 77px;
            font-weight: bold;
        }
        .style69
        {
            width: 118px;
            font-weight: bold;
            height: 12px;
        }
        .style70
        {
            width: 199px;
            height: 12px;
        }
        .style72
        {
            width: 182px;
            height: 12px;
        }
        .style74
        {
            width: 77px;
            height: 12px;
        }
        .style75
        {
            height: 12px;
        }
        .style76
        {
            width: 118px;
            height: 22px;
        }
        .style77
        {
            width: 117px;
            height: 22px;
        }
        .style82
        {
            width: 199px;
            height: 22px;
        }
        .style84
        {
            width: 182px;
            height: 22px;
        }
        .style85
        {
            width: 77px;
            height: 22px;
        }
        .style86
        {
            height: 22px;
        }
        .style87
        {
            width: 4px;
            height: 25px;
        }
        .style88
        {
            width: 32px;
            font-weight: bold;
            height: 25px;
        }
        .style89
        {
            width: 144px;
            height: 25px;
        }
        .style90
        {
            width: 163px;
            height: 25px;
        }
        .style91
        {
            width: 173px;
            height: 25px;
        }
        .style92
        {
            width: 76px;
            height: 25px;
        }
        .style93
        {
            width: 131px;
            height: 25px;
        }
        .style94
        {
            width: 47px;
            height: 25px;
        }
        .style95
        {
            width: 4px;
            height: 22px;
        }
        .style96
        {
            width: 4px;
        }
        </style>
</head>
<body>
    <form id="form1" runat="server">
    <br />
    <table class="style28">
        <tr>
            <td class="style95">
                &nbsp;</td>
            <td class="style8">
                &nbsp;</td>
            <td class="style12">
                &nbsp;</td>
            <td class="style16">
                &nbsp;</td>
            <td class="style14">
                &nbsp;</td>
            <td class="style18">
                &nbsp;</td>
            <td class="style20">
                &nbsp;</td>
            <td class="style22">
                &nbsp;</td>
            <td class="style11">
                &nbsp;</td>
            <td class="style24">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style96">
                &nbsp;</td>
            <td class="style3">
                &nbsp;</td>
            <td class="style13">
                &nbsp;</td>
            <td class="style17">
                &nbsp;</td>
            <td class="style15">
                &nbsp;</td>
            <td class="style19">
                &nbsp;</td>
            <td class="style21">
                &nbsp;</td>
            <td class="style23">
                &nbsp;</td>
            <td class="style11">
                &nbsp;</td>
            <td class="style24">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style96">
                &nbsp;</td>
            <td class="style27">
                Type</td>
            <td class="style13">
 
                <asp:DropDownList ID="DropDownTYPE" runat="server" AutoPostBack="True"  
                    DataSourceID="SqlDataSourceTYPE" DataTextField="Categ"  
                    DataValueField="Num_categ" Height="18px" Width="154px">
                </asp:DropDownList>
 
            </td>
            <td class="style17">
                <asp:TextBox ID="TextBoxtype" runat="server" Width="149px" Height="22px"></asp:TextBox>
            </td>
            <td class="style15">
                <asp:Button ID="Button1" runat="server" Text="Ajouter" style="height: 26px" />
            </td>
            <td class="style19">
                &nbsp;</td>
            <td class="style21">
                &nbsp;</td>
            <td class="style23">
                &nbsp;</td>
            <td class="style11">
                &nbsp;</td>
            <td class="style24">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style96">
                &nbsp;</td>
            <td class="style3">
                &nbsp;</td>
            <td class="style13">
                &nbsp;</td>
            <td class="style17">
                &nbsp;</td>
            <td class="style15">
                &nbsp;</td>
            <td class="style19">
                &nbsp;</td>
            <td class="style21">
                &nbsp;</td>
            <td class="style23">
                &nbsp;</td>
            <td class="style11">
                &nbsp;</td>
            <td class="style24">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style87">
                </td>
            <td class="style88">
                Marque</td>
            <td class="style89">
    <asp:DropDownList ID="DropDownMARQUE" runat="server" AutoPostBack="True"  
        DataSourceID="SqlDataSourceMARQUE" DataTextField="marque" DataValueField="marque"  
        Height="17px" Width="151px">
        <asp:ListItem>.Sans</asp:ListItem>
    </asp:DropDownList>
            </td>
            <td class="style90">
                &nbsp;</td>
            <td class="style26">
                Modèle</td>
            <td class="style91">
                <asp:DropDownList ID="DropDownMODEL" runat="server" AutoPostBack="True"  
                    DataSourceID="SqlDataSourceMODEL" DataTextField="modele" DataValueField="modele"  
                    style="height: 18px; width: 143px">
                </asp:DropDownList>
            </td>
            <td class="style92">
                &nbsp;</td>
            <td class="style25">
                Numéro</td>
            <td class="style93">
                <asp:DropDownList ID="DropDownNUM" runat="server" AutoPostBack="True"  
                    DataSourceID="SqlDataSourceNUM" DataTextField="numero" DataValueField="numero"  
                    Height="25px" Width="142px">
                </asp:DropDownList>
            </td>
            <td class="style94">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style96">
                &nbsp;</td>
            <td class="style3">
                &nbsp;</td>
            <td class="style13">
                <asp:TextBox ID="TextBoxmarque" runat="server" Width="150px"></asp:TextBox>
            </td>
            <td class="style17">
                <asp:Button ID="Button5" runat="server" Height="26px" Text="Ajouter" />
            </td>
            <td class="style15">
                &nbsp;</td>
            <td class="style19">
                <asp:TextBox ID="TextBoxmodele" runat="server" Width="143px"></asp:TextBox>
            </td>
            <td class="style21">
                <asp:Button ID="Button2" runat="server" Text="Ajouter" />
            </td>
            <td class="style23">
                &nbsp;</td>
            <td class="style11">
                <asp:TextBox ID="TextBoxnumero" runat="server" Width="136px"></asp:TextBox>
            </td>
            <td class="style24">
                <asp:Button ID="Button3" runat="server" Text="Ajouter" />
            </td>
        </tr>
    </table>
    <br />
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"  
        DataKeyNames="code_materiel" DataSourceID="SqlDataSource1" Height="133px"  
        RowHeaderColumn="code_materiel" Width="111px">
        <Columns>
            <asp:BoundField DataField="code_materiel" HeaderText="code_materiel"  
                InsertVisible="False" ReadOnly="True" SortExpression="code_materiel" />
        </Columns>
    </asp:GridView>
&nbsp;<br />
    <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"></asp:TextBox>
&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:Button ID="Button7" runat="server" Text="test" Width="36px" />
    <table class="style28">
        <tr>
            <td class="style33">
                Numéro de série</td>
            <td class="style47">
                <asp:TextBox ID="TextBoxnumserie" runat="server" Width="150px"></asp:TextBox>
            </td>
            <td class="style55">
                Code barre</td>
            <td class="style31">
                <asp:TextBox ID="TextBoxcodebarre" runat="server" Width="151px"></asp:TextBox>
            </td>
            <td class="style64">
                Fournisseur</td>
            <td>
                <asp:DropDownList ID="DropDownfournisseur" runat="server" AutoPostBack="True"  
                    DataSourceID="SqlDataSourceFOURNISSEUR" DataTextField="nom_fournisseur"  
                    DataValueField="id_fournisseur" Height="16px" Width="164px">
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td class="style76">
            </td>
            <td class="style82">
                &nbsp;</td>
            <td class="style77">
            </td>
            <td class="style84">
            </td>
            <td class="style85">
            </td>
            <td class="style86">
            </td>
        </tr>
        <tr>
            <td class="style37">
                Date de réception</td>
            <td class="style47">
                <dxe:ASPxDateEdit ID="ASPxDateEdit1" runat="server"  
                    CssFilePath="~/App_Themes/BlackGlass/{0}/styles.css" CssPostfix="BlackGlass"  
                    Height="24px" ImageFolder="~/App_Themes/BlackGlass/{0}/" Width="171px">
                    <ButtonStyle Width="11px">
                    </ButtonStyle>
                    <ValidationSettings>
                        <ErrorImage Height="14px" Url="~/App_Themes/BlackGlass/Editors/Error.gif"  
                            Width="14px" />
                        <ErrorFrameStyle ImageSpacing="4px">
                            <ErrorTextPaddings PaddingLeft="4px" />
                        </ErrorFrameStyle>
                    </ValidationSettings>
                    <CalendarProperties>
                        <HeaderStyle Spacing="1px" />
                        <FooterStyle Spacing="4px" />
                        <FastNavProperties Enabled="False" />
                    </CalendarProperties>
                </dxe:ASPxDateEdit>
            </td>
            <td class="style55">
                Date fin garantie</td>
            <td class="style31">
                <dxe:ASPxDateEdit ID="ASPxDateEdit2" runat="server"  
                    CssFilePath="~/App_Themes/BlackGlass/{0}/styles.css" CssPostfix="BlackGlass"  
                    ImageFolder="~/App_Themes/BlackGlass/{0}/" height="24px" width="171px">
                    <ButtonStyle Width="11px">
                    </ButtonStyle>
                    <ValidationSettings>
                        <ErrorImage Height="14px" Url="~/App_Themes/BlackGlass/Editors/Error.gif"  
                            Width="14px" />
                        <ErrorFrameStyle ImageSpacing="4px">
                            <ErrorTextPaddings PaddingLeft="4px" />
                        </ErrorFrameStyle>
                    </ValidationSettings>
                    <CalendarProperties>
                        <HeaderStyle Spacing="1px" />
                        <FooterStyle Spacing="4px" />
                    </CalendarProperties>
                </dxe:ASPxDateEdit>
            </td>
            <td class="style61">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style39">
            </td>
            <td class="style48">
            </td>
            <td class="style56">
            </td>
            <td class="style42">
            </td>
            <td class="style62">
            </td>
            <td class="style40">
            </td>
        </tr>
        <tr>
            <td class="style69">
                &nbsp;</td>
            <td class="style70">
                &nbsp;</td>
            <td class="style54">
                &nbsp;</td>
            <td class="style72">
                &nbsp;</td>
            <td class="style74">
                &nbsp;</td>
            <td class="style75">
            </td>
        </tr>
    </table>
    <br />
                <asp:Button ID="Button6" runat="server" Text="Ajouter le materiel"  
        style="text-align: left; margin-top: 0px" Width="133px" />
                &nbsp;
                <br />
    <br />
<asp:SqlDataSource ID="SqlDataSourceMARQUE" runat="server"  
                    ConnectionString="<%$ ConnectionStrings:CTIPARKConnectionString1 %>"  
                     
        SelectCommand="SELECT DISTINCT [marque] FROM [materiel]">
                </asp:SqlDataSource>
            <asp:SqlDataSource ID="SqlDataSourceNUM" runat="server"  
        ConnectionString="<%$ ConnectionStrings:CTIPARKConnectionString1 %>"  
         
        SelectCommand="SELECT DISTINCT [numero] FROM [materiel] WHERE (([Num_categ] = @Num_categ) AND ([marque] = @marque) AND ([modele] = @modele))">
                <SelectParameters>
                    <asp:ControlParameter ControlID="DropDownTYPE" Name="Num_categ"  
                        PropertyName="SelectedValue" Type="Int32" />
                    <asp:ControlParameter ControlID="DropDownMARQUE" Name="marque"  
                        PropertyName="SelectedValue" Type="String" />
                    <asp:ControlParameter ControlID="DropDownMODEL" Name="modele"  
                        PropertyName="SelectedValue" Type="String" />
                </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSourceTYPE" runat="server"  
        ConnectionString="<%$ ConnectionStrings:CTIPARKConnectionString1 %>"  
        SelectCommand="SELECT DISTINCT [Num_categ], [Categ] FROM [type_materiel]"></asp:SqlDataSource>
                <asp:SqlDataSource ID="SqlDataSourceMODEL" runat="server"  
                    ConnectionString="<%$ ConnectionStrings:CTIPARKConnectionString1 %>"  
                     
        SelectCommand="SELECT DISTINCT [modele] FROM [materiel] WHERE (([Num_categ] = @Num_categ) AND ([marque] = @marque))">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="DropDownTYPE" Name="Num_categ"  
                            PropertyName="SelectedValue" Type="Int32" />
                        <asp:ControlParameter ControlID="DropDownMARQUE" Name="marque"  
                            PropertyName="SelectedValue" Type="String" />
                    </SelectParameters>
                </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSourcesave" runat="server"  
        ConnectionString="<%$ ConnectionStrings:CTIPARKConnectionString1 %>"  
         
                                 
        SelectCommand="SELECT * FROM [parc]">
    </asp:SqlDataSource>
                            <asp:SqlDataSource ID="SqlDataSourceFOURNISSEUR" runat="server"  
                                ConnectionString="<%$ ConnectionStrings:CTIPARKConnectionString1 %>"  
                                SelectCommand="SELECT DISTINCT [id_fournisseur], [nom_fournisseur] FROM [fournisseur]">
                            </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSourcetest" runat="server"  
        ConnectionString="<%$ ConnectionStrings:CTIPARKConnectionString1 %>" SelectCommand="select right(max(id_materiel),2)+1 from parc
where left(id_materiel,3)= 109"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"  
        ConnectionString="<%$ ConnectionStrings:CTIPARKConnectionString1 %>"  
        SelectCommand="SELECT [code_materiel] FROM [materiel] WHERE (([Num_categ] = @Num_categ) AND ([marque] = @marque) AND ([modele] = @modele) AND ([numero] = @numero))">
        <SelectParameters>
            <asp:ControlParameter ControlID="DropDownTYPE" Name="Num_categ"  
                PropertyName="SelectedValue" Type="Int32" />
            <asp:ControlParameter ControlID="DropDownMARQUE" Name="marque"  
                PropertyName="SelectedValue" Type="String" />
            <asp:ControlParameter ControlID="DropDownMODEL" Name="modele"  
                PropertyName="SelectedValue" Type="String" />
            <asp:ControlParameter ControlID="DropDownNUM" Name="numero"  
                PropertyName="SelectedValue" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server"  
        ConnectionString="<%$ ConnectionStrings:CTIPARKConnectionString1 %>"  
        SelectCommand="SELECT [code_materiel] FROM [materiel] WHERE (([Num_categ] = @Num_categ) AND ([marque] = @marque) AND ([modele] = @modele) AND ([numero] = @numero))">
        <SelectParameters>
            <asp:ControlParameter ControlID="DropDownTYPE" Name="Num_categ"  
                PropertyName="SelectedValue" Type="Int32" />
            <asp:ControlParameter ControlID="DropDownMARQUE" Name="marque"  
                PropertyName="SelectedValue" Type="String" />
            <asp:ControlParameter ControlID="DropDownMODEL" Name="modele"  
                PropertyName="SelectedValue" Type="String" />
            <asp:ControlParameter ControlID="DropDownNUM" Name="numero"  
                PropertyName="SelectedValue" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    <br />
    <br />
    &nbsp;&nbsp;&nbsp;
    </form>
</body>
</html>
 
le code vb est
Partial Class page1
    Inherits System.Web.UI.Page
 
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        SqlDataSourceTYPE.InsertCommand = "INSERT INTO type_materiel(categ) VALUES ('" + TextBoxtype.Text + "')"
        SqlDataSourceTYPE.Insert()
        TextBoxtype.Text = ""
    End Sub
 
    Protected Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
        SqlDataSourceMARQUE.InsertCommand = "INSERT INTO materiel (Num_categ, marque,modele, numero) VALUES ('" + DropDownTYPE.SelectedValue + "', '" + TextBoxmarque.Text + "', '.Sans Modele', '.Sans Numero')"
        SqlDataSourceMARQUE.Insert()
        TextBoxmarque.Text = ""
    End Sub
 
    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        SqlDataSourceMODEL.InsertCommand = "INSERT INTO materiel (Num_categ, marque,modele,numero) VALUES ('" + DropDownTYPE.SelectedValue + "', '" + DropDownMARQUE.SelectedValue + "', '" + TextBoxmodele.Text + "','.Sans Numero')"
        SqlDataSourceMODEL.Insert()
        TextBoxmodele.Text = ""
    End Sub
 
    Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
        SqlDataSourceNUM.InsertCommand = "INSERT INTO materiel (Num_categ, marque,modele,numero) VALUES ('" + DropDownTYPE.SelectedValue + "', '" + DropDownMARQUE.SelectedValue + "', '" + DropDownMODEL.SelectedValue + "', '" + TextBoxnumero.Text + "')"
        SqlDataSourceNUM.Insert()
        TextBoxnumero.Text = ""
    End Sub
 
    Protected Sub Button6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button6.Click
        SqlDataSourcesave.InsertCommand = "insert into parc (id_materiel,num_serie,code_barre,code_materiel,id_etat,date_reception,date_f_garantie) values (10933,'" + TextBoxnumserie.Text + "','" + TextBoxcodebarre.Text + "','" + GridView1.SelectedValue + "',1,'" + ASPxDateEdit1.Text + "','" + ASPxDateEdit2.Text + "') "
        SqlDataSourcesave.Insert()
        TextBoxcodebarre.Text = ""
        TextBoxnumserie.Text = ""
        ASPxDateEdit1.Text = ""
        ASPxDateEdit2.Text = ""
    End Sub
 
    Protected Sub Button7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button7.Click
        TextBox1.Text = GridView1.SelectedRow.Cells(1).Text
    End Sub
End Class

Reply

Marsh Posté le 02-12-2009 à 10:32:54    

Pour ma culture, c'est pas plutôt du VB.net ça ?

Reply

Marsh Posté le 02-12-2009 à 12:20:30    

j'ai essayé avec gridview1.selectedrow.cell(0).text est ca ne marche tjr pas j'ai tjr le message d'erreur: la reference d'objets n'est pas definie a une instance d'un objet

Reply

Marsh Posté le 02-12-2009 à 14:42:53    

j'ai bien compris, j'ai mis gridview1.row(0).cells(0).text et ca marche a merveille, je vous remercie, fnalement cette ereur m'as servi de comprendre le principe des griview grace a votre aide
merci

Reply

Marsh Posté le    

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed