C#/XAML: Get Textbox value from DataTemplate Textbox in DataGridView





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















The sitatuion:



I've a DataGridView on my WPF Application that is connected to my SQL server.
I created a Textbox, which doesn't really exist, inside a DataTemplate.



<DataGridTemplateColumn Header="Amount">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox x:Name="txtAmount"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>


This ensures that every column has a Textbox. Now I want to get the Textbox value from the currentcell or the last cell where some value is put in (on the DataGridView) and I want use this value to insert the value in another column of the database table.
I have approached many sources but unfortunately I don't know how to implement this inside my program. I tried something with Binding, but that didn't work out.



I hope someone can help me with my problem.










share|improve this question























  • use binding,MVVM framework with Xaml

    – mahlatse
    Nov 23 '18 at 16:47











  • Did any of the solution help you? If no, update your question providing more details. In other case mark the answer you were looking for/ was useful to you.

    – Karol Żurowski
    Nov 26 '18 at 7:17


















0















The sitatuion:



I've a DataGridView on my WPF Application that is connected to my SQL server.
I created a Textbox, which doesn't really exist, inside a DataTemplate.



<DataGridTemplateColumn Header="Amount">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox x:Name="txtAmount"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>


This ensures that every column has a Textbox. Now I want to get the Textbox value from the currentcell or the last cell where some value is put in (on the DataGridView) and I want use this value to insert the value in another column of the database table.
I have approached many sources but unfortunately I don't know how to implement this inside my program. I tried something with Binding, but that didn't work out.



I hope someone can help me with my problem.










share|improve this question























  • use binding,MVVM framework with Xaml

    – mahlatse
    Nov 23 '18 at 16:47











  • Did any of the solution help you? If no, update your question providing more details. In other case mark the answer you were looking for/ was useful to you.

    – Karol Żurowski
    Nov 26 '18 at 7:17














0












0








0








The sitatuion:



I've a DataGridView on my WPF Application that is connected to my SQL server.
I created a Textbox, which doesn't really exist, inside a DataTemplate.



<DataGridTemplateColumn Header="Amount">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox x:Name="txtAmount"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>


This ensures that every column has a Textbox. Now I want to get the Textbox value from the currentcell or the last cell where some value is put in (on the DataGridView) and I want use this value to insert the value in another column of the database table.
I have approached many sources but unfortunately I don't know how to implement this inside my program. I tried something with Binding, but that didn't work out.



I hope someone can help me with my problem.










share|improve this question














The sitatuion:



I've a DataGridView on my WPF Application that is connected to my SQL server.
I created a Textbox, which doesn't really exist, inside a DataTemplate.



<DataGridTemplateColumn Header="Amount">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox x:Name="txtAmount"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>


This ensures that every column has a Textbox. Now I want to get the Textbox value from the currentcell or the last cell where some value is put in (on the DataGridView) and I want use this value to insert the value in another column of the database table.
I have approached many sources but unfortunately I don't know how to implement this inside my program. I tried something with Binding, but that didn't work out.



I hope someone can help me with my problem.







c# xml xaml textbox datatemplate






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 16:34









ICT FreakICT Freak

32




32













  • use binding,MVVM framework with Xaml

    – mahlatse
    Nov 23 '18 at 16:47











  • Did any of the solution help you? If no, update your question providing more details. In other case mark the answer you were looking for/ was useful to you.

    – Karol Żurowski
    Nov 26 '18 at 7:17



















  • use binding,MVVM framework with Xaml

    – mahlatse
    Nov 23 '18 at 16:47











  • Did any of the solution help you? If no, update your question providing more details. In other case mark the answer you were looking for/ was useful to you.

    – Karol Żurowski
    Nov 26 '18 at 7:17

















use binding,MVVM framework with Xaml

– mahlatse
Nov 23 '18 at 16:47





use binding,MVVM framework with Xaml

– mahlatse
Nov 23 '18 at 16:47













Did any of the solution help you? If no, update your question providing more details. In other case mark the answer you were looking for/ was useful to you.

– Karol Żurowski
Nov 26 '18 at 7:17





Did any of the solution help you? If no, update your question providing more details. In other case mark the answer you were looking for/ was useful to you.

– Karol Żurowski
Nov 26 '18 at 7:17












2 Answers
2






active

oldest

votes


















0














If you set the data context for your DataGrid, datagrid's row inherits that ( row's data context is a single element from the collection that you are binding your DataGrid to).



If you want to bind to some value outside DataGrid, that's a tricky case, because the column doesn’t belong to the visual or logical tree of the DataGrid. You have to use some kind of proxy






share|improve this answer
























  • Thanks for your answer. It was helpful.

    – ICT Freak
    Dec 31 '18 at 10:02











  • @ICTFreak No problem, you can vote up my answer if you want to:)

    – Karol Żurowski
    Dec 31 '18 at 10:09



















0














Make use of Textbox.TextChanged event. If you are using MVVM, bind a method with converter to obtain data from the cell that has changed..
Use this value to apply on any other column.



You can make use of converterparameter to bind in the cell where you will need to make changes...






share|improve this answer
























  • Thanks for your answer. It was helpful.

    – ICT Freak
    Dec 31 '18 at 10:01












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53450225%2fc-xaml-get-textbox-value-from-datatemplate-textbox-in-datagridview%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














If you set the data context for your DataGrid, datagrid's row inherits that ( row's data context is a single element from the collection that you are binding your DataGrid to).



If you want to bind to some value outside DataGrid, that's a tricky case, because the column doesn’t belong to the visual or logical tree of the DataGrid. You have to use some kind of proxy






share|improve this answer
























  • Thanks for your answer. It was helpful.

    – ICT Freak
    Dec 31 '18 at 10:02











  • @ICTFreak No problem, you can vote up my answer if you want to:)

    – Karol Żurowski
    Dec 31 '18 at 10:09
















0














If you set the data context for your DataGrid, datagrid's row inherits that ( row's data context is a single element from the collection that you are binding your DataGrid to).



If you want to bind to some value outside DataGrid, that's a tricky case, because the column doesn’t belong to the visual or logical tree of the DataGrid. You have to use some kind of proxy






share|improve this answer
























  • Thanks for your answer. It was helpful.

    – ICT Freak
    Dec 31 '18 at 10:02











  • @ICTFreak No problem, you can vote up my answer if you want to:)

    – Karol Żurowski
    Dec 31 '18 at 10:09














0












0








0







If you set the data context for your DataGrid, datagrid's row inherits that ( row's data context is a single element from the collection that you are binding your DataGrid to).



If you want to bind to some value outside DataGrid, that's a tricky case, because the column doesn’t belong to the visual or logical tree of the DataGrid. You have to use some kind of proxy






share|improve this answer













If you set the data context for your DataGrid, datagrid's row inherits that ( row's data context is a single element from the collection that you are binding your DataGrid to).



If you want to bind to some value outside DataGrid, that's a tricky case, because the column doesn’t belong to the visual or logical tree of the DataGrid. You have to use some kind of proxy







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 23 '18 at 16:50









Karol ŻurowskiKarol Żurowski

175111




175111













  • Thanks for your answer. It was helpful.

    – ICT Freak
    Dec 31 '18 at 10:02











  • @ICTFreak No problem, you can vote up my answer if you want to:)

    – Karol Żurowski
    Dec 31 '18 at 10:09



















  • Thanks for your answer. It was helpful.

    – ICT Freak
    Dec 31 '18 at 10:02











  • @ICTFreak No problem, you can vote up my answer if you want to:)

    – Karol Żurowski
    Dec 31 '18 at 10:09

















Thanks for your answer. It was helpful.

– ICT Freak
Dec 31 '18 at 10:02





Thanks for your answer. It was helpful.

– ICT Freak
Dec 31 '18 at 10:02













@ICTFreak No problem, you can vote up my answer if you want to:)

– Karol Żurowski
Dec 31 '18 at 10:09





@ICTFreak No problem, you can vote up my answer if you want to:)

– Karol Żurowski
Dec 31 '18 at 10:09













0














Make use of Textbox.TextChanged event. If you are using MVVM, bind a method with converter to obtain data from the cell that has changed..
Use this value to apply on any other column.



You can make use of converterparameter to bind in the cell where you will need to make changes...






share|improve this answer
























  • Thanks for your answer. It was helpful.

    – ICT Freak
    Dec 31 '18 at 10:01
















0














Make use of Textbox.TextChanged event. If you are using MVVM, bind a method with converter to obtain data from the cell that has changed..
Use this value to apply on any other column.



You can make use of converterparameter to bind in the cell where you will need to make changes...






share|improve this answer
























  • Thanks for your answer. It was helpful.

    – ICT Freak
    Dec 31 '18 at 10:01














0












0








0







Make use of Textbox.TextChanged event. If you are using MVVM, bind a method with converter to obtain data from the cell that has changed..
Use this value to apply on any other column.



You can make use of converterparameter to bind in the cell where you will need to make changes...






share|improve this answer













Make use of Textbox.TextChanged event. If you are using MVVM, bind a method with converter to obtain data from the cell that has changed..
Use this value to apply on any other column.



You can make use of converterparameter to bind in the cell where you will need to make changes...







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 24 '18 at 0:07









Senguttuvan MahalingamSenguttuvan Mahalingam

834




834













  • Thanks for your answer. It was helpful.

    – ICT Freak
    Dec 31 '18 at 10:01



















  • Thanks for your answer. It was helpful.

    – ICT Freak
    Dec 31 '18 at 10:01

















Thanks for your answer. It was helpful.

– ICT Freak
Dec 31 '18 at 10:01





Thanks for your answer. It was helpful.

– ICT Freak
Dec 31 '18 at 10:01


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53450225%2fc-xaml-get-textbox-value-from-datatemplate-textbox-in-datagridview%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Paul Cézanne

UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

Angular material date-picker (MatDatepicker) auto completes the date on focus out