Click here to Skip to main content
15,890,438 members
Home / Discussions / C#
   

C#

 
GeneralRe: DAL Responses Design Question Pin
Ravi Bhavnani21-Apr-14 7:41
professionalRavi Bhavnani21-Apr-14 7:41 
GeneralRe: DAL Responses Design Question Pin
Kevin Marois21-Apr-14 8:10
professionalKevin Marois21-Apr-14 8:10 
QuestionHow to develop on Windows 7 64 bit and output x32 exe that uses x32 usb driver ? Pin
Mario 5620-Apr-14 2:46
Mario 5620-Apr-14 2:46 
AnswerRe: How to develop on Windows 7 64 bit and output x32 exe that uses x32 usb driver ? Pin
OriginalGriff20-Apr-14 3:43
mveOriginalGriff20-Apr-14 3:43 
GeneralRe: How to develop on Windows 7 64 bit and output x32 exe that uses x32 usb driver ? Pin
Mario 5620-Apr-14 6:32
Mario 5620-Apr-14 6:32 
Questionhow to code to c# method call on html anchor tag but that anchor tag is placed in datalist. Pin
Ayang1719-Apr-14 9:14
Ayang1719-Apr-14 9:14 
AnswerRe: how to code to c# method call on html anchor tag but that anchor tag is placed in datalist. Pin
Wes Aday19-Apr-14 10:35
professionalWes Aday19-Apr-14 10:35 
QuestionDoubleClick Selected Row Datagrid (C# WPF Project) Pin
rattlerrFx19-Apr-14 8:27
rattlerrFx19-Apr-14 8:27 
I am currently getting an error that I am having a bit of trouble trying to figure out here is the code below that I am working with:

Xaml Code:
XML
<DataGrid Height="418"  VerticalAlignment="Top" IsReadOnly="True" Width="846" ItemsSource="{Binding Path=MyDataBinding}" Name="datagrid1" BorderBrush="#FF0C5900" Style="{DynamicResource DataGridStyle1}" Background="#FF1F1F1F" ColumnHeaderHeight="30" ColumnWidth="127" BorderThickness="1,0,0,1" SelectionMode="Single" RowHeight="40" FontSize="14">
               <DataGrid.RowStyle>
                   <Style TargetType="{x:Type DataGridRow}">
                       <EventSetter Event="MouseDoubleClick" Handler="DataGrid_MouseDoubleClick"/>
                   </Style>
               </DataGrid.RowStyle>
           </DataGrid>


C#
private void DataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
       {
           DataGridRow dgr = sender as DataGridRow;
           DataRowView drv = dgr.DataContext as DataRowView;

           string hybridInfo = drv.Row["HybridInfo"].ToString();

           conConnect = new SqlConnection("Data Source=GERRY;Initial Catalog=MMJDB;Integrated Security=True");
           SqlCommand cmd = new SqlCommand("SELECT * FROM StrainInfo WHERE HybridInfo=@HybridInfo");
           cmd.Connection = conConnect;
           cmd.Parameters.AddWithValue("@HybridInfo", hybridInfo);
           conConnect.Open();

           dAdapter = new SqlDataAdapter(cmd);
           DS = new DataSet();

           dAdapter.Fill(DS, "MyDataBinding");

           datagrid2.ItemsSource = DS.Tables[0].AsDataView();

           dAdapter.Dispose();
           conConnect.Close();

       }


The line of code that is producing the following error:
A first chance exception of type 'System.ArgumentException' occurred in System.Data.dll

Additional information: Column 'HybridInfo' does not belong to table MyDataBinding

C#
string hybridInfo = drv.Row["HybridInfo"].ToString();


modified 19-Apr-14 14:59pm.

AnswerRe: DoubleClick Selected Row Datagrid (C# WPF Project) Pin
Wes Aday19-Apr-14 10:34
professionalWes Aday19-Apr-14 10:34 
GeneralRe: DoubleClick Selected Row Datagrid (C# WPF Project) Pin
rattlerrFx19-Apr-14 12:10
rattlerrFx19-Apr-14 12:10 
GeneralRe: DoubleClick Selected Row Datagrid (C# WPF Project) Pin
Wes Aday20-Apr-14 2:22
professionalWes Aday20-Apr-14 2:22 
GeneralRe: DoubleClick Selected Row Datagrid (C# WPF Project) Pin
rattlerrFx20-Apr-14 4:24
rattlerrFx20-Apr-14 4:24 
GeneralRe: DoubleClick Selected Row Datagrid (C# WPF Project) Pin
Wes Aday20-Apr-14 4:29
professionalWes Aday20-Apr-14 4:29 
SuggestionRe: DoubleClick Selected Row Datagrid (C# WPF Project) Pin
Richard MacCutchan19-Apr-14 21:20
mveRichard MacCutchan19-Apr-14 21:20 
QuestionDisplaying UTM coordinates on a form Pin
Member 1068390219-Apr-14 8:07
Member 1068390219-Apr-14 8:07 
QuestionDraw a Line within a class and inheritance Pin
Member 1075956718-Apr-14 16:55
Member 1075956718-Apr-14 16:55 
SuggestionRe: Draw a Line within a class and inheritance Pin
Richard MacCutchan18-Apr-14 22:04
mveRichard MacCutchan18-Apr-14 22:04 
QuestionPartial Snippet Pin
Mycroft Holmes18-Apr-14 16:30
professionalMycroft Holmes18-Apr-14 16:30 
AnswerRe: Partial Snippet Pin
Richard MacCutchan18-Apr-14 21:59
mveRichard MacCutchan18-Apr-14 21:59 
GeneralRe: Partial Snippet Pin
Mycroft Holmes19-Apr-14 2:38
professionalMycroft Holmes19-Apr-14 2:38 
AnswerRe: Partial Snippet Pin
OriginalGriff19-Apr-14 4:31
mveOriginalGriff19-Apr-14 4:31 
Questiona concept I'm trying to build Pin
solo918-Apr-14 15:07
solo918-Apr-14 15:07 
GeneralRe: a concept I'm trying to build Pin
Richard MacCutchan18-Apr-14 21:57
mveRichard MacCutchan18-Apr-14 21:57 
Questioni want to hyperlink connect with stringquery and also display same hyperlink on other page Pin
Member 1061806718-Apr-14 12:12
Member 1061806718-Apr-14 12:12 
AnswerRe: i want to hyperlink connect with stringquery and also display same hyperlink on other page Pin
Richard Andrew x6418-Apr-14 12:19
professionalRichard Andrew x6418-Apr-14 12:19 

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.