As you have provided minimal details, I can only give a relatively high-level answer but the normal way to do this relies on you having used data binding to bind your grid to an underlying data source. What you would normally consider, in situations like this, is checking the input value to see that it is not present in the grid. Without any more information from you, I can't begin to show you how this would be accomplished.
You might want to consider adding details about the model that you are binding the datagrid to get a more detailed answer.
Okay, given your updates, you should be able to solve this with a couple of simple fixes. The first thing I would do is make channels a member variable rather than a local variable.
private IEnumerable<ChannelIndex> channels;
private void GetData()
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("https://localhost:44324/");
HttpResponseMessage rsponse = client.GetAsync("api/Channels").Result;
channels = rsponse.Content.ReadAsAsync<IEnumerable<Channelindex>>().Result;
usergrid.ItemsSource = channels;
MessageBox.Show("Error Code" +
rsponse.StatusCode + " : Message - " + rsponse.ReasonPhrase);
With your populated enumerable, you now have the ability to find duplicates. To do this, you could use a simple LINQ query to check whether or not the item is present. Your duplicate check method might look something like this:
private bool IsChannelAlreadyPresent(string url)
return channels.Any((channel) => string.Equals(channel.url, url, StringComparison.CurrentCultureIgnoreCase));
You can then use this method from your add click handler to check for a duplicate entry.